-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-31416: Fix assertion failures in case of a bad warnings.filters or warnings.defaultaction #3496
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-31416: Fix assertion failures in case of a bad warnings.filters or warnings.defaultaction #3496
Conversation
Python/_warnings.c
Outdated
|
|
||
| if (!PyUnicode_Check(default_action)) { | ||
| PyErr_SetString(PyExc_TypeError, | ||
| "warnings.defaultaction must be a string"); |
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.
Use MODULE_NAME, as in other error messages. Include an actual type name in error message.
Python/_warnings.c
Outdated
|
|
||
| if (!PyUnicode_Check(action)) { | ||
| PyErr_SetString(PyExc_TypeError, | ||
| "action must be a string"); |
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.
Include an actual type name in error message.
|
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 |
…ters or warnings.defaultaction. (pythonGH-3496) Patch by Oren Milman.. (cherry picked from commit 9d984fd)
|
GH-3509 is a backport of this pull request to the 3.6 branch. |
_warnings.c: add checks whether the action retrieved from warnings.filters is not a string, and whether warnings.defaultaction is not a string. while we are here, remove a wrong error message.test_warnings/__init__.py: add a test to verify that the assertion failures are no more.https://bugs.python.org/issue31416