[issue21762] update the import machinery to only use __spec__

Nick Coghlan report at bugs.python.org
Fri Jan 15 23:52:12 EST 2016


Nick Coghlan added the comment:

My concern is more about backwards compatibility - at the moment, you can alter the behaviour of import, pickle, and other subsystems by modifying the module level attributes, and if we switch to preferring the __spec__ attributes, then that kind of code will break (I added an import specific example related to __main__ module relative imports to the linked issue).

That's not to say it shouldn't be done - as you say, it would be nice to eventually get to a point where the import system only needs access to the module spec and not to the runtime state, and there are also cases where the __spec__ information will be more correct (e.g. pickling objects in __main__).

However, it needs to be in such a way that there are appropriate porting notes that explain to people why their state mutations stopped having the desired effect, and what (if anything) they can do instead.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21762>
_______________________________________


More information about the Python-bugs-list mailing list