mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
This commit is contained in:
parent
a180b007d9
commit
a24107b04c
31 changed files with 538 additions and 242 deletions
|
|
@ -339,7 +339,7 @@ get_attrib_from_keywords(PyObject *kwds)
|
|||
if (attrib_str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
PyObject *attrib = PyDict_GetItem(kwds, attrib_str);
|
||||
PyObject *attrib = PyDict_GetItemWithError(kwds, attrib_str);
|
||||
|
||||
if (attrib) {
|
||||
/* If attrib was found in kwds, copy its value and remove it from
|
||||
|
|
@ -356,7 +356,8 @@ get_attrib_from_keywords(PyObject *kwds)
|
|||
Py_DECREF(attrib);
|
||||
attrib = NULL;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else if (!PyErr_Occurred()) {
|
||||
attrib = PyDict_New();
|
||||
}
|
||||
|
||||
|
|
@ -1393,9 +1394,13 @@ _elementtree_Element_get_impl(ElementObject *self, PyObject *key,
|
|||
if (!self->extra || self->extra->attrib == Py_None)
|
||||
value = default_value;
|
||||
else {
|
||||
value = PyDict_GetItem(self->extra->attrib, key);
|
||||
if (!value)
|
||||
value = PyDict_GetItemWithError(self->extra->attrib, key);
|
||||
if (!value) {
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
value = default_value;
|
||||
}
|
||||
}
|
||||
|
||||
Py_INCREF(value);
|
||||
|
|
@ -2848,11 +2853,12 @@ makeuniversal(XMLParserObject* self, const char* string)
|
|||
if (!key)
|
||||
return NULL;
|
||||
|
||||
value = PyDict_GetItem(self->names, key);
|
||||
value = PyDict_GetItemWithError(self->names, key);
|
||||
|
||||
if (value) {
|
||||
Py_INCREF(value);
|
||||
} else {
|
||||
}
|
||||
else if (!PyErr_Occurred()) {
|
||||
/* new name. convert to universal name, and decode as
|
||||
necessary */
|
||||
|
||||
|
|
@ -2974,7 +2980,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in,
|
|||
if (!key)
|
||||
return;
|
||||
|
||||
value = PyDict_GetItem(self->entity, key);
|
||||
value = PyDict_GetItemWithError(self->entity, key);
|
||||
|
||||
if (value) {
|
||||
if (TreeBuilder_CheckExact(self->target))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue