-
-
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-39912: Raise appropriate exceptions in filterwarnings() and simplefilter() #18878
Conversation
Lib/warnings.py
Outdated
"once"), "invalid action: %r" % (action,) | ||
assert isinstance(lineno, int) and lineno >= 0, \ | ||
"lineno must be an int >= 0" | ||
if action not in ("error", "ignore", "always", "default", "module", "once"): |
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.
What about the category
argument?
Also it may be worth to move the duplicated code into a subfunction.
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.
The category argument is a bit different, it's supposed to be a subclass of Warning
and nothing else but in some cases like https://github.com/python/cpython/blob/master/Lib/unittest/test/test_case.py#L1435 it will get called with a tuple.
Should we relax the condition on category so it accepts tuples of Warning
subclasses too or fix unittest
so it calls simplefilter() multiple time when given a iterable?
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
https://bugs.python.org/issue39912
https://bugs.python.org/issue16845
https://bugs.python.org/issue21865