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
|
@ -86,6 +86,12 @@ get_once_registry(void)
|
|||
return NULL;
|
||||
return _PyRuntime.warnings.once_registry;
|
||||
}
|
||||
if (!PyDict_Check(registry)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"warnings.onceregistry must be a dict");
|
||||
Py_DECREF(registry);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(_PyRuntime.warnings.once_registry);
|
||||
_PyRuntime.warnings.once_registry = registry;
|
||||
return registry;
|
||||
|
@ -437,7 +443,7 @@ warn_explicit(PyObject *category, PyObject *message,
|
|||
Py_RETURN_NONE;
|
||||
|
||||
if (registry && !PyDict_Check(registry) && (registry != Py_None)) {
|
||||
PyErr_SetString(PyExc_TypeError, "'registry' must be a dict");
|
||||
PyErr_SetString(PyExc_TypeError, "'registry' must be a dict or None");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue