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 a427e35..f37b8a7 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -162,7 +162,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) | 
