mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-112075: Fix race in constructing dict for instance (#118499)
This commit is contained in:
parent
430945db4c
commit
636b8d94c9
4 changed files with 216 additions and 71 deletions
|
@ -1731,7 +1731,7 @@ _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
|
|||
goto done;
|
||||
}
|
||||
else {
|
||||
res = _PyObjectDict_SetItem(tp, dictptr, name, value);
|
||||
res = _PyObjectDict_SetItem(tp, obj, dictptr, name, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1789,7 +1789,9 @@ PyObject_GenericSetDict(PyObject *obj, PyObject *value, void *context)
|
|||
"not a '%.200s'", Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
Py_BEGIN_CRITICAL_SECTION(obj);
|
||||
Py_XSETREF(*dictptr, Py_NewRef(value));
|
||||
Py_END_CRITICAL_SECTION();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue