Skip to content
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

Merged
merged 3 commits into from
May 15, 2018
Merged

bpo-33509: Fix _warnings for module_globals=None #6833

merged 3 commits into from
May 15, 2018

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented May 14, 2018

Don't crash on warnings.warn_explicit() if module_globals is None.

https://bugs.python.org/issue33509

Don't crash on warnings.warn_explicit() if module_globals is None.
@@ -883,6 +883,13 @@ get_source_line(PyObject *module_globals, int lineno)
PyObject *source_list;
PyObject *source_line;

if (!PyDict_Check(module_globals)) {
Copy link
Member

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().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -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'",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why " "?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@serhiy-storchaka
Copy link
Member

Sorry, I don't see you latest changes Victor.

@vstinner
Copy link
Member Author

Sorry, I don't see you latest changes Victor.

Woops. I just forgot to commit my changes... They are now published.

@vstinner vstinner merged commit b056562 into python:master May 15, 2018
@bedevere-bot
Copy link

@vstinner: Please replace # with GH- in the commit message next time. Thanks!

@vstinner vstinner deleted the warn_explicit_None branch May 15, 2018 18:42
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 15, 2018
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>
@bedevere-bot
Copy link

GH-6870 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request May 15, 2018
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants