bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)

This commit is contained in:
Serhiy Storchaka 2019-02-25 17:59:46 +02:00 committed by GitHub
parent a180b007d9
commit a24107b04c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 538 additions and 242 deletions

View file

@ -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) {