Skip to content

Commit

Permalink
object.c: fix race when accessing attributes and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
colesbury committed Apr 23, 2023
1 parent ea1160c commit 212fef4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,9 +1257,9 @@ _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method)
}
if (dict != NULL) {
Py_INCREF(dict);
PyObject *attr = PyDict_GetItemWithError(dict, name);
PyObject *attr = PyDict_FetchItemWithError(dict, name);
if (attr != NULL) {
*method = Py_NewRef(attr);
*method = attr;
Py_DECREF(dict);
Py_XDECREF(descr);
return 0;
Expand Down Expand Up @@ -1381,9 +1381,8 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
}
if (dict != NULL) {
Py_INCREF(dict);
res = PyDict_GetItemWithError(dict, name);
res = PyDict_FetchItemWithError(dict, name);
if (res != NULL) {
Py_INCREF(res);
Py_DECREF(dict);
goto done;
}
Expand Down

0 comments on commit 212fef4

Please sign in to comment.