Skip to content

Commit 8a29421

Browse files
committed
pythongh-130327: Only set the managed dictionary if there aren't inline values
1 parent c26bed1 commit 8a29421

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Objects/dictobject.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -7170,15 +7170,16 @@ set_dict_inline_values(PyObject *obj, PyDictObject *new_dict)
71707170

71717171
PyDictValues *values = _PyObject_InlineValues(obj);
71727172

7173-
Py_XINCREF(new_dict);
7174-
FT_ATOMIC_STORE_PTR(_PyObject_ManagedDictPointer(obj)->dict, new_dict);
7175-
71767173
if (values->valid) {
71777174
FT_ATOMIC_STORE_UINT8(values->valid, 0);
71787175
for (Py_ssize_t i = 0; i < values->capacity; i++) {
71797176
Py_CLEAR(values->values[i]);
71807177
}
71817178
}
7179+
else {
7180+
Py_XINCREF(new_dict);
7181+
FT_ATOMIC_STORE_PTR(_PyObject_ManagedDictPointer(obj)->dict, new_dict);
7182+
}
71827183
}
71837184

71847185
#ifdef Py_GIL_DISABLED

0 commit comments

Comments
 (0)