mirror of
https://github.com/python/cpython.git
synced 2025-10-03 21:55:41 +00:00
[3.6] bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (GH-3485). (#3494)
(cherry picked from commit 252033d50e
)
This commit is contained in:
parent
c67838da2c
commit
7972ed2111
3 changed files with 20 additions and 1 deletions
|
@ -94,6 +94,12 @@ get_once_registry(void)
|
|||
return NULL;
|
||||
return _once_registry;
|
||||
}
|
||||
if (!PyDict_Check(registry)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"warnings.onceregistry must be a dict");
|
||||
Py_DECREF(registry);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(_once_registry);
|
||||
_once_registry = registry;
|
||||
return registry;
|
||||
|
@ -449,7 +455,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