Skip to content
Prev Previous commit
Next Next commit
Merge branch 'main' into use-dict_getitemref
  • Loading branch information
serhiy-storchaka committed Nov 14, 2023
commit 7863509f25e58692454a244dd03523975fc571fe
1 change: 0 additions & 1 deletion Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,6 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
}
if (dict != NULL) {
Py_INCREF(dict);
res = PyDict_GetItemWithError(dict, name);
int rc = PyDict_GetItemRef(dict, name, &res);
Py_DECREF(dict);
if (res != NULL) {
Expand Down
16 changes: 9 additions & 7 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,9 +1432,11 @@ type_get_doc(PyTypeObject *type, void *context)
if (PyDict_GetItemRef(dict, &_Py_ID(__doc__), &result) == 0) {
result = Py_NewRef(Py_None);
}
else if (result && Py_TYPE(result)->tp_descr_get) {
Py_SETREF(result, Py_TYPE(result)->tp_descr_get(result, NULL,
(PyObject *)type));
else if (result) {
descrgetfunc descr_get = Py_TYPE(result)->tp_descr_get;
if (descr_get) {
Py_SETREF(result, descr_get(result, NULL, (PyObject *)type));
}
}
return result;
}
Expand Down Expand Up @@ -1469,9 +1471,9 @@ type_get_annotations(PyTypeObject *type, void *context)
return NULL;
}
if (annotations) {
if (Py_TYPE(annotations)->tp_descr_get) {
Py_SETREF(annotations, Py_TYPE(annotations)->tp_descr_get(
annotations, NULL, (PyObject *)type));
descrgetfunc get = Py_TYPE(annotations)->tp_descr_get;
if (get) {
Py_SETREF(annotations, get(annotations, NULL, (PyObject *)type));
}
}
else {
Expand Down Expand Up @@ -1523,7 +1525,7 @@ type_get_type_params(PyTypeObject *type, void *context)
{
PyObject *params;
if (PyDict_GetItemRef(lookup_tp_dict(type), &_Py_ID(__type_params__), &params) == 0) {
params = PyTuple_New(0);
return PyTuple_New(0);
}
return params;
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.