]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Ensure that warnings.filters is properly restored after fiddling with it
authorGreg Ward <gward@python.net>
Mon, 7 Mar 2005 01:10:33 +0000 (01:10 +0000)
committerGreg Ward <gward@python.net>
Mon, 7 Mar 2005 01:10:33 +0000 (01:10 +0000)
(this was breaking test_warnings).

Lib/test/test_descr.py

index 4af59b000da8bf37c69f562a07cf1b9aaa361fcc..1601e4d8f341aee0fe718ef5015f9582a9fa6e50 100644 (file)
@@ -3973,15 +3973,18 @@ def test_init():
         def __init__(self):
             return 10
 
-    oldfilters = warnings.filters
-    warnings.filterwarnings("error", category=RuntimeWarning)
+    oldfilters = warnings.filters[:]
     try:
-        Foo()
-    except RuntimeWarning:
         pass
-    else:
-        raise TestFailed, "did not test __init__() for None return"
-    warnings.filters = oldfilters
+        warnings.filterwarnings("error", category=RuntimeWarning)
+        try:
+            Foo()
+        except RuntimeWarning:
+            pass
+        else:
+            raise TestFailed, "did not test __init__() for None return"
+    finally:
+        warnings.filters = oldfilters
 
 
 def test_main():