From 004547f97067be2e23ae770f300c0c0d1db1ba27 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 11 Sep 2017 10:01:31 +0300 Subject: [2.7] bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (GH-3485). (#3493) (cherry picked from commit 252033d50effa08046ac34fcc406bc99796ab88b) --- Lib/test/test_warnings.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Lib/test/test_warnings.py') diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 607d9f9b72..0023363832 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -584,6 +584,17 @@ class _WarningsTests(BaseTest): self.assertNotIn(b'Warning!', stderr) self.assertNotIn(b'Error', stderr) + @test_support.cpython_only + def test_issue31411(self): + # warn_explicit() shouldn't raise a SystemError in case + # warnings.onceregistry isn't a dictionary. + wmod = self.module + with original_warnings.catch_warnings(module=wmod): + wmod.filterwarnings('once') + with test_support.swap_attr(wmod, 'onceregistry', None): + with self.assertRaises(TypeError): + wmod.warn_explicit('foo', Warning, 'bar', 1, registry=None) + class WarningsDisplayTests(unittest.TestCase): -- cgit v1.2.1