hyperkai · GitHub

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

Read the original on github.com ↗