-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Closed as not planned
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Setting the float value 3.14 to lineno argument of warnings.filterwarnings() and warnings.simplefilter() gets the error message as shown below:
import warnings
# ↓ ↓ ↓ ↓ ↓ ↓
warnings.filterwarnings(action="ignore", lineno=3.14) # Error
warnings.simplefilter(action="ignore", lineno=3.14) # Error
# ↑ ↑ ↑ ↑ ↑ ↑
print(warnings.filters)AssertionError: lineno must be an int >= 0
But setting the bool values True and False to lineno argument of warnings.filterwarnings() and warnings.simplefilter() works as shown below:
import warnings
# ↓ ↓ ↓ ↓ ↓ ↓
warnings.filterwarnings(action="ignore", lineno=True)
warnings.filterwarnings(action="ignore", lineno=False)
# ↑ ↑ ↑ ↑ ↑ ↑
# ↓ ↓ ↓ ↓ ↓ ↓
warnings.simplefilter(action="ignore", lineno=True)
warnings.simplefilter(action="ignore", lineno=False)
# ↑ ↑ ↑ ↑ ↑ ↑
print(warnings.filters)
# [('ignore', None, <class 'Warning'>, None, False),
# ('ignore', None, <class 'Warning'>, None, True)]CPython versions tested on:
3.12
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error