[New-bugs-announce] [issue31411] SystemError raised by warn_explicit() in case warnings.onceregistry is not a dict

Oren Milman report at bugs.python.org
Sun Sep 10 13:37:43 EDT 2017


New submission from Oren Milman:

The following code causes warn_explicit() (in Python/_warnings.c) to raise a
SystemError:

import warnings
warnings.filterwarnings('once')
warnings.onceregistry = None
warnings.warn_explicit(message='foo', category=Warning, filename='bar',
                       lineno=1, registry=None)


this is because warn_explicit() assumes that warnings.onceregistry is a dict,
and passes it to update_registry(), which passes it to already_warned(), which
eventually passes it to _PyDict_SetItemId(), which raises the SystemError.

----------
components: Extension Modules
messages: 301822
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: SystemError raised by warn_explicit() in case warnings.onceregistry is not a dict
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31411>
_______________________________________


More information about the New-bugs-announce mailing list