Commit 0b752287 authored by Yury Selivanov's avatar Yury Selivanov Committed by GitHub

bpo-34042: Fix dict.copy() to maintain correct total refcount (GH-8119)

parent dc9bc548
Fix dict.copy() to maintain correct total refcount (as reported by
sys.gettotalrefcount()).
......@@ -656,6 +656,13 @@ clone_combined_dict(PyDictObject *orig)
/* Maintain tracking. */
_PyObject_GC_TRACK(new);
}
/* Since we copied the keys table we now have an extra reference
in the system. Manually call _Py_INC_REFTOTAL to signal that
we have it now; calling DK_INCREF would be an error as
keys->dk_refcnt is already set to 1 (after memcpy). */
_Py_INC_REFTOTAL;
return (PyObject *)new;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment