Skip to content

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

Merged
vstinner merged 3 commits intopython:masterfrom
vstinner:warn_explicit_None
May 15, 2018
Merged

bpo-33509: Fix _warnings for module_globals=None#6833
vstinner merged 3 commits intopython:masterfrom
vstinner:warn_explicit_None

Conversation

@vstinner
Copy link
Copy Markdown
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.
Comment thread Python/_warnings.c Outdated
PyObject *source_list;
PyObject *source_line;

if (!PyDict_Check(module_globals)) {
Copy link
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

Comment thread Python/_warnings.c Outdated

if (!PyDict_Check(module_globals)) {
PyErr_Format(PyExc_TypeError,
"module_globals must be a dict, " "not '%.200s'",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why " "?

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@vstinner
Copy link
Copy Markdown
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
Copy Markdown

@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
Copy Markdown
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
Copy Markdown

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