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-39912: Raise appropriate exceptions in filterwarnings() and simplefilter() #18878

Merged
merged 6 commits into from
Dec 1, 2023

Conversation

remilapeyre
Copy link
Contributor

@remilapeyre remilapeyre commented Mar 9, 2020

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"):
Copy link
Member

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.

Copy link
Contributor Author

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?

Rémi Lapeyre and others added 2 commits April 8, 2020 15:26
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) December 1, 2023 11:10
@serhiy-storchaka serhiy-storchaka merged commit a65a3d4 into python:main Dec 1, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
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.

5 participants