-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary #3485
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-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary #3485
Conversation
Python/_warnings.c
Outdated
@@ -514,6 +514,11 @@ warn_explicit(PyObject *category, PyObject *message, | |||
registry = get_once_registry(); | |||
if (registry == NULL) | |||
goto cleanup; | |||
if (!PyDict_Check(registry)) { |
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 add this check in get_once_registry()
.
Thank you for your PR @orenmn. Do you mind to add a NEWS.d entry? |
Thanks @orenmn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6. |
Sorry, @orenmn and @serhiy-storchaka, I could not cleanly backport this to |
…egistry is not a dictionary. (pythonGH-3485). (cherry picked from commit 252033d)
GH-3493 is a backport of this pull request to the 2.7 branch. |
…egistry is not a dictionary. (pythonGH-3485). (cherry picked from commit 252033d)
GH-3494 is a backport of this pull request to the 3.6 branch. |
_warnings.c
: add a check whether warnings.onceregistry is not a dictionary. while we are here, fix a related inaccurate error message.test_warnings/__init__.py
: add a test to verify that the SystemError is no more.https://bugs.python.org/issue31411