We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc9bc54 commit 0b75228Copy full SHA for 0b75228
Misc/NEWS.d/next/Core and Builtins/2018-07-05-15-51-29.bpo-34042.Gr9XUH.rst
@@ -0,0 +1,2 @@
1
+Fix dict.copy() to maintain correct total refcount (as reported by
2
+sys.gettotalrefcount()).
Objects/dictobject.c
@@ -656,6 +656,13 @@ clone_combined_dict(PyDictObject *orig)
656
/* Maintain tracking. */
657
_PyObject_GC_TRACK(new);
658
}
659
+
660
+ /* Since we copied the keys table we now have an extra reference
661
+ in the system. Manually call _Py_INC_REFTOTAL to signal that
662
+ we have it now; calling DK_INCREF would be an error as
663
+ keys->dk_refcnt is already set to 1 (after memcpy). */
664
+ _Py_INC_REFTOTAL;
665
666
return (PyObject *)new;
667
668
0 commit comments