This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Update importlib.__init__ to reset _frozen_importlib's loader to SourceFileLoader
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, eric.snow
Priority: low Keywords:

Created on 2014-04-23 15:01 by brett.cannon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg217073 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-04-23 15:01
When importlib.__init__ tries to mask the fact that _frozen_importlib is frozen it should also reset __loader__ to be an instance of SourceFileLoader. This will allow tracebacks to include source lines thanks to SourceFileLoader.get_source().
msg217759 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-05-02 17:05
Even with setting SourceFileLoader, you still don't get file lines back. Why? Because all of the constructed objects in _frozen_importlib have their co_filename set before the back-patching in importlib.__init__ and so when the traceback module tries to do its thing it sees '<frozen importlib._bootstrap>' as the filename instead of importlib._bootstrap.__file__ which doesn't lead to linecache getting anything useful.

IOW a whole lot of effort for code that people should never have to look at.
msg251852 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2015-09-29 12:47
The underlying issue extends to all frozen modules.  I've opened #25268 to consider how we might address it.
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65534
2015-09-29 12:47:25eric.snowsetnosy: + eric.snow
messages: + msg251852
2014-05-02 17:05:55brett.cannonsetstatus: open -> closed
resolution: rejected
messages: + msg217759
2014-04-23 15:07:38zach.waresettitle: Update importlib.__init__ to reset _frozen_imnportlib's loader to SourceFileLoader -> Update importlib.__init__ to reset _frozen_importlib's loader to SourceFileLoader
2014-04-23 15:01:51brett.cannoncreate