{"action":"created","issue":{"url":"https://api.github.com/repos/inducer/pudb/issues/246","repository_url":"https://api.github.com/repos/inducer/pudb","labels_url":"https://api.github.com/repos/inducer/pudb/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/inducer/pudb/issues/246/comments","events_url":"https://api.github.com/repos/inducer/pudb/issues/246/events","html_url":"https://github.com/inducer/pudb/pull/246","id":219955007,"number":246,"title":"Added option to hide importlib frames in stack","user":{"login":"wronglink","id":668115,"avatar_url":"https://avatars1.githubusercontent.com/u/668115?v=3","gravatar_id":"","url":"https://api.github.com/users/wronglink","html_url":"https://github.com/wronglink","followers_url":"https://api.github.com/users/wronglink/followers","following_url":"https://api.github.com/users/wronglink/following{/other_user}","gists_url":"https://api.github.com/users/wronglink/gists{/gist_id}","starred_url":"https://api.github.com/users/wronglink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wronglink/subscriptions","organizations_url":"https://api.github.com/users/wronglink/orgs","repos_url":"https://api.github.com/users/wronglink/repos","events_url":"https://api.github.com/users/wronglink/events{/privacy}","received_events_url":"https://api.github.com/users/wronglink/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-04-06T16:24:37Z","updated_at":"2017-04-13T19:42:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/inducer/pudb/pulls/246","html_url":"https://github.com/inducer/pudb/pull/246","diff_url":"https://github.com/inducer/pudb/pull/246.diff","patch_url":"https://github.com/inducer/pudb/pull/246.patch"},"body":"I've made some research and here are the results:\r\n\r\n1. As big part of python import system since python3.3 is mostly implemented in python, we now catch some importlib frames.\r\n2. Actually it's a [well known bug](http://bugs.python.org/issue15110), and they have also made a hack over it. They added a special function [`_call_with_frames_removed`](https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/importlib/_bootstrap.py#L196) that marks you code for [`import.c`](https://github.com/python/cpython/blob/aefa7ebf0ff0f73feee7ab24f4cdcb2014d83ee5/Python/import.c#L1277) machinery that it must be cleaned up after `__import__` call. But I guess it doesn't work for our case, because we interrupt code inside the import.\r\n\r\nI think that best solution for us is to add optional stack clean-up of importlib trash frames at the view level. It would hide some inner python magic for most of users, but will also leave a way to debug importlib machinery (for example when custom import Finders and Loaders are being developed).\r\n\r\nBefore:\r\n![2017-04-06_18-58-05](https://cloud.githubusercontent.com/assets/668115/24764664/bc81972e-1afd-11e7-9f58-c640432264d5.png)\r\n\r\nAfter:\r\n![2017-04-06_18-58-40](https://cloud.githubusercontent.com/assets/668115/24764671/c36ad136-1afd-11e7-9e11-e48b2a56ab21.png)\r\n\r\nFixes #109 "},"comment":{"url":"https://api.github.com/repos/inducer/pudb/issues/comments/294002486","html_url":"https://github.com/inducer/pudb/pull/246#issuecomment-294002486","issue_url":"https://api.github.com/repos/inducer/pudb/issues/246","id":294002486,"user":{"login":"wronglink","id":668115,"avatar_url":"https://avatars1.githubusercontent.com/u/668115?v=3","gravatar_id":"","url":"https://api.github.com/users/wronglink","html_url":"https://github.com/wronglink","followers_url":"https://api.github.com/users/wronglink/followers","following_url":"https://api.github.com/users/wronglink/following{/other_user}","gists_url":"https://api.github.com/users/wronglink/gists{/gist_id}","starred_url":"https://api.github.com/users/wronglink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wronglink/subscriptions","organizations_url":"https://api.github.com/users/wronglink/orgs","repos_url":"https://api.github.com/users/wronglink/repos","events_url":"https://api.github.com/users/wronglink/events{/privacy}","received_events_url":"https://api.github.com/users/wronglink/received_events","type":"User","site_admin":false},"created_at":"2017-04-13T19:42:38Z","updated_at":"2017-04-13T19:42:38Z","body":"Yes it does. I don't see any way to clean-up importlib frames from system stack (and also, don't think it's good idea). What we do:\r\n\r\n0. Override the `Bdb.get_stack` method, and clean-up all hidden frames (if needed) there.\r\n1. Detect the top unhidden frame at the `set_trace` call (actually, I call `self.get_stack` and get the top frame from there).\r\n2. Send the cleaned-up stack to the UI, so there will be no imporlib trash and no way to accidentally go to importlib frame."}}
{"actor":{"display_login":"wronglink"}}