Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r89411:2cf5804b5f91
Date: 2017-01-08 15:24 +0100
http://bitbucket.org/pypy/pypy/changeset/2cf5804b5f91/

Log:    Fix the exception class we get

diff --git a/pypy/module/_warnings/interp_warnings.py 
b/pypy/module/_warnings/interp_warnings.py
--- a/pypy/module/_warnings/interp_warnings.py
+++ b/pypy/module/_warnings/interp_warnings.py
@@ -69,12 +69,12 @@
     # Validate category
     try:
         if not space.abstract_issubclass_w(w_category, space.w_Warning):
-            raise oefmt(space.w_ValueError,
+            raise oefmt(space.w_TypeError,
                         "category is not a subclass of Warning")
     except OperationError as e:
         if e.async(space):
             raise
-        raise oefmt(space.w_ValueError,
+        raise oefmt(space.w_TypeError,
                     "category must be a Warning subclass, not '%T'",
                     w_category)
 
diff --git a/pypy/module/_warnings/test/test_warnings.py 
b/pypy/module/_warnings/test/test_warnings.py
--- a/pypy/module/_warnings/test/test_warnings.py
+++ b/pypy/module/_warnings/test/test_warnings.py
@@ -80,3 +80,10 @@
         _warnings.warn('test', UserWarning)
         globals()['__file__'] = None
         _warnings.warn('test', UserWarning)
+
+    def test_bad_category(self):
+        import _warnings
+        raises(TypeError, _warnings.warn, "text", 123)
+        class Foo:
+            pass
+        raises(TypeError, _warnings.warn, "text", Foo)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to