summaryrefslogtreecommitdiffstats
path: root/Objects/odictobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/odictobject.c')
-rw-r--r--Objects/odictobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 4eb15f9..6c7f117 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -1814,6 +1814,11 @@ odictiter_iternext(odictiterobject *di)
Py_INCREF(result);
Py_DECREF(PyTuple_GET_ITEM(result, 0)); /* borrowed */
Py_DECREF(PyTuple_GET_ITEM(result, 1)); /* borrowed */
+ // bpo-42536: The GC may have untracked this result tuple. Since we're
+ // recycling it, make sure it's tracked again:
+ if (!_PyObject_GC_IS_TRACKED(result)) {
+ _PyObject_GC_TRACK(result);
+ }
}
else {
result = PyTuple_New(2);