-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-31676: Fix test_imp.test_load_source() side effect #3871
Conversation
Lib/test/test_imp.py
Outdated
tmp_mod = type(sys.modules[__name__])(__name__) | ||
with support.swap_item(sys.modules, __name__, tmp_mod): | ||
with self.assertRaisesRegex(ValueError, 'embedded null'): | ||
imp.load_source(__name__, __file__ + "\0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be safe to not use the name of an existing module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test_load_source() now replaces the current __name__ module with a temporary module to prevent side effects.
Thanks @Haypo for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
GH-3988 is a backport of this pull request to the 3.6 branch. |
test_load_source() now replaces the current
__name__
module with atemporary module to prevent side effects.
https://bugs.python.org/issue31676