Message364947
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. |
|
Date |
User |
Action |
Args |
2020-03-24 17:09:11 | brett.cannon | set | recipients:
+ brett.cannon, ncoghlan, vstinner, eric.snow, corona10, shihai1991 |
2020-03-24 17:09:11 | brett.cannon | set | messageid: <1585069751.25.0.945850373073.issue40050@roundup.psfhosted.org> |
2020-03-24 17:09:11 | brett.cannon | link | issue40050 messages |
2020-03-24 17:09:11 | brett.cannon | create | |
|