diff options
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r-- | Lib/warnings.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py index 70d087e..5ca4b9c 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -169,7 +169,9 @@ def warn(message, category=None, stacklevel=1): # Check category argument if category is None: category = UserWarning - assert issubclass(category, Warning) + if not (isinstance(category, type) and issubclass(category, Warning)): + raise TypeError("category must be a Warning subclass, " + "not '{:s}'".format(type(category).__name__)) # Get context information try: caller = sys._getframe(stacklevel) |