[issue15230] runpy.run_path doesn't set __package__ correctly

Nick Coghlan report at bugs.python.org
Sat Jul 7 13:21:53 CEST 2012


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Sorry, that's not accurate - you have enough code in b.py to make the relative import work by convincing the interpreter it's actually being done in a package.

So what you're seeing in that regard is the fact that runpy is not any kind of sandbox - it shares process global state, including the import system, with all other modules. While the temporary module will be reverted automatically by runpy, any child imports will always remain visible in sys.modules, and any other side effects will remain in place (e.g. codec registrations).

----------

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


More information about the Python-bugs-list mailing list