diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-02-25 17:59:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 17:59:46 +0200 |
commit | a24107b04c1277e3c1105f98aff5bfa3a98b33a0 (patch) | |
tree | 55aa5a700e08e3ba27b0361df2b1043be5c4701a /Python/bltinmodule.c | |
parent | a180b007d96fe68b32f11dec720fbd0cd5b6758a (diff) | |
download | cpython-git-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.gz |
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index f9b901f7e5..eebdc5ba05 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -142,7 +142,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, return NULL; } - meta = _PyDict_GetItemId(mkw, &PyId_metaclass); + meta = _PyDict_GetItemIdWithError(mkw, &PyId_metaclass); if (meta != NULL) { Py_INCREF(meta); if (_PyDict_DelItemId(mkw, &PyId_metaclass) < 0) { @@ -154,6 +154,11 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, /* metaclass is explicitly given, check if it's indeed a class */ isclass = PyType_Check(meta); } + else if (PyErr_Occurred()) { + Py_DECREF(mkw); + Py_DECREF(bases); + return NULL; + } } if (meta == NULL) { /* if there are no bases, use type: */ @@ -956,11 +961,14 @@ builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals, return NULL; } - if (_PyDict_GetItemId(globals, &PyId___builtins__) == NULL) { + if (_PyDict_GetItemIdWithError(globals, &PyId___builtins__) == NULL) { if (_PyDict_SetItemId(globals, &PyId___builtins__, PyEval_GetBuiltins()) != 0) return NULL; } + else if (PyErr_Occurred()) { + return NULL; + } if (PyCode_Check(source)) { if (PyCode_GetNumFree((PyCodeObject *)source) > 0) { @@ -1036,11 +1044,14 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals, locals->ob_type->tp_name); return NULL; } - if (_PyDict_GetItemId(globals, &PyId___builtins__) == NULL) { + if (_PyDict_GetItemIdWithError(globals, &PyId___builtins__) == NULL) { if (_PyDict_SetItemId(globals, &PyId___builtins__, PyEval_GetBuiltins()) != 0) return NULL; } + else if (PyErr_Occurred()) { + return NULL; + } if (PyCode_Check(source)) { if (PyCode_GetNumFree((PyCodeObject *)source) > 0) { |