Brett Cannon <br...@python.org> added the comment:

>From Victor:
* Maybe the test_importlib should before save/restore the the "Python state" 
rather than modifying modules

You will have to be more specific than that as there is an import_state() 
context manager to control import state via the sys module.


* Maybe module.__spec__ should leak less importlib internals: explicitly clear 
namespaces? Use static methods? I'm not sure how to do that.

Are you saying change everything on __spec__ objects to be static methods? That 
won't work because the whole point of __spec__ objects is to essentially be 
data classes to store details of a module.

* Remove module.__spec__? ... that would mean rejecting PEP 451 implemented in 
Python 3.4, that sounds like a major regression :-(

No. You would break the world and undo years of work to clean up import 
semantics with no good way to go back to the old way.

Can I ask why you suddenly want to throw __spec__ objects out due to a leak 
tied back to _weakref switching to multi-phase initialization? Also note that 
the use of weakrefs by importlib isn't tied to __spec__ objects but to 
per-module import locks in importlib._bootstrap.

----------

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

Reply via email to