From: Brett Cannon Date: Thu, 8 May 2008 20:20:24 +0000 (+0000) Subject: Fix a bug introduced by the addition of the 'record' argument to X-Git-Tag: v2.6b1~575 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d023c3afacf4af2bcaedcb63305a36e179f0236;p=python Fix a bug introduced by the addition of the 'record' argument to test.test_support.catch_warning() where showwarning() was not being set properly. --- diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 25494a919c..9a45fdde8d 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -406,11 +406,11 @@ def catch_warning(module=warnings, record=True): warnings.warn("foo") assert str(w.message) == "foo" """ + original_filters = module.filters[:] + original_showwarning = module.showwarning if record: warning_obj = WarningMessage() module.showwarning = warning_obj._showwarning - original_filters = module.filters[:] - original_showwarning = module.showwarning try: yield warning_obj if record else None finally: