Nick Coghlan <ncogh...@gmail.com> added the comment:

In that case, how about we go with:

1. By default, importlib._bootstrap is never imported. Instead, it is set to be 
a reference to _frozen_importlib. However, _frozen_importlib does *not* lie 
about where it came from (and doesn't assume the on-disk source matches the 
frozen source).

2. We provide two private functions in importlib.__init__: one that replaces 
all _frozen_importlib references in the import state with importlib._bootstrap 
references (retrieving the latter from disk first), and one that reverses the 
process.

Note that the __import__ builtin should be replaced as well, since that will 
otherwise call in to the frozen version of the module.

This is basically the same as Eric Snow's suggestion, just with most of the 
nuts and bolts kept within importlib, so that the testing context manager 
doesn't need to know the details - it can just call the appropriate importlib 
functions to change the active implementation.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14657>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to