diff options
author | Oren Milman <orenmn@gmail.com> | 2017-09-11 06:28:39 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-11 06:28:39 (GMT) |
commit | 252033d50effa08046ac34fcc406bc99796ab88b (patch) | |
tree | da5a9acc3a8a57688769bba6bbaaebce741846a4 /Lib/test/test_warnings | |
parent | 3866d9bbcf808cea98b3d00007f9f246b83858ce (diff) | |
download | cpython-252033d50effa08046ac34fcc406bc99796ab88b.zip cpython-252033d50effa08046ac34fcc406bc99796ab88b.tar.gz cpython-252033d50effa08046ac34fcc406bc99796ab88b.tar.bz2 |
bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (#3485)
Diffstat (limited to 'Lib/test/test_warnings')
-rw-r--r-- | Lib/test/test_warnings/__init__.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py index 69623c4..75539cf 100644 --- a/Lib/test/test_warnings/__init__.py +++ b/Lib/test/test_warnings/__init__.py @@ -794,6 +794,17 @@ class _WarningsTests(BaseTest, unittest.TestCase): self.assertNotIn(b'Warning!', stderr) self.assertNotIn(b'Error', stderr) + @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 support.swap_attr(wmod, 'onceregistry', None): + with self.assertRaises(TypeError): + wmod.warn_explicit('foo', Warning, 'bar', 1, registry=None) + class WarningsDisplayTests(BaseTest): |