Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit127bd9b

Browse files
bpo-34042: Fix dict.copy() to maintain correct total refcount (GH-8119)
(cherry picked from commit0b75228)Co-authored-by: Yury Selivanov <yury@magic.io>
1 parent4bd5fce commit127bd9b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix dict.copy() to maintain correct total refcount (as reported by
2+
sys.gettotalrefcount()).

‎Objects/dictobject.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,13 @@ clone_combined_dict(PyDictObject *orig)
656656
/* Maintain tracking. */
657657
_PyObject_GC_TRACK(new);
658658
}
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+
659666
return (PyObject*)new;
660667
}
661668

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp