summaryrefslogtreecommitdiff
path: root/Lib/test/test_warnings.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-09-11 10:01:31 +0300
committerGitHub <noreply@github.com>2017-09-11 10:01:31 +0300
commit004547f97067be2e23ae770f300c0c0d1db1ba27 (patch)
treef61e4c139de7fe44d7458193edb08c93ac2c99f6 /Lib/test/test_warnings.py
parent6ed7aff8948e50708f048f3f7fd41809259d1777 (diff)
downloadcpython-git-004547f97067be2e23ae770f300c0c0d1db1ba27.tar.gz
[2.7] bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (GH-3485). (#3493)
(cherry picked from commit 252033d50effa08046ac34fcc406bc99796ab88b)
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r--Lib/test/test_warnings.py11
1 files changed, 11 insertions, 0 deletions
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):