Skip to content

Commit 212fef4

Browse files
committed
object.c: fix race when accessing attributes and methods
1 parent ea1160c commit 212fef4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

‎Objects/object.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,9 @@ _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method)
12571257
}
12581258
if (dict != NULL) {
12591259
Py_INCREF(dict);
1260-
PyObject *attr = PyDict_GetItemWithError(dict, name);
1260+
PyObject *attr = PyDict_FetchItemWithError(dict, name);
12611261
if (attr != NULL) {
1262-
*method = Py_NewRef(attr);
1262+
*method = attr;
12631263
Py_DECREF(dict);
12641264
Py_XDECREF(descr);
12651265
return 0;
@@ -1381,9 +1381,8 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
13811381
}
13821382
if (dict != NULL) {
13831383
Py_INCREF(dict);
1384-
res = PyDict_GetItemWithError(dict, name);
1384+
res = PyDict_FetchItemWithError(dict, name);
13851385
if (res != NULL) {
1386-
Py_INCREF(res);
13871386
Py_DECREF(dict);
13881387
goto done;
13891388
}

0 commit comments

Comments
 (0)