mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (#3485)
This commit is contained in:
parent
3866d9bbcf
commit
252033d50e
3 changed files with 20 additions and 1 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue