-
-
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-33509: Fix _warnings for module_globals=None #6833
Conversation
Don't crash on warnings.warn_explicit() if module_globals is None.
Python/_warnings.c
Outdated
@@ -883,6 +883,13 @@ get_source_line(PyObject *module_globals, int lineno) | |||
PyObject *source_list; | |||
PyObject *source_line; | |||
|
|||
if (!PyDict_Check(module_globals)) { |
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.
I would move this check into warnings_warn_explicit()
.
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.
fixed
Python/_warnings.c
Outdated
@@ -883,6 +883,13 @@ get_source_line(PyObject *module_globals, int lineno) | |||
PyObject *source_list; | |||
PyObject *source_line; | |||
|
|||
if (!PyDict_Check(module_globals)) { | |||
PyErr_Format(PyExc_TypeError, | |||
"module_globals must be a dict, " "not '%.200s'", |
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.
Why " "
?
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.
fixed
Sorry, I don't see you latest changes Victor. |
Woops. I just forgot to commit my changes... They are now published. |
@vstinner: Please replace |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Don't crash on warnings.warn_explicit() if module_globals is not a dict. (cherry picked from commit b056562) Co-authored-by: Victor Stinner <vstinner@redhat.com>
GH-6870 is a backport of this pull request to the 3.7 branch. |
Don't crash on warnings.warn_explicit() if module_globals is None.
https://bugs.python.org/issue33509