-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Setting the int
type value 100
to category
argument of warnings.warn() gets the error message as shown below:
import warnings
# ↓ ↓ Here ↓ ↓
warnings.warn(message='This is a warning', category=100) # Error
TypeError: category must be a Warning subclass, not 'int'
But the superclass Warning also works as shown below:
import warnings
# ↓ ↓ ↓ Here ↓ ↓ ↓
warnings.warn(message='This is a warning', category=Warning)
# Warning: This is a warning
# warnings.warn(message='This is a warning', category=Warning)
So, the error message should be something like as shown below:
TypeError: category must be a Warning superclass or Warning subclass, not 'int'
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error