diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-11 07:01:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-11 07:01:47 (GMT) |
commit | 7972ed2111ea2f01e8712eef91bcf2260e05ad8b (patch) | |
tree | 81e77d1a781507636b6d547ddeb6f20b8d1c458f /Python | |
parent | c67838da2cde6fa3f1bef11f08719237983e6990 (diff) | |
download | cpython-7972ed2111ea2f01e8712eef91bcf2260e05ad8b.zip cpython-7972ed2111ea2f01e8712eef91bcf2260e05ad8b.tar.gz cpython-7972ed2111ea2f01e8712eef91bcf2260e05ad8b.tar.bz2 |
[3.6] bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (GH-3485). (#3494)
(cherry picked from commit 252033d50effa08046ac34fcc406bc99796ab88b)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/_warnings.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 6cfae77..2b04b90 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -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; } |