Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Lib/test/test_structseq.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
import copy
import gc
import os
import pickle
import re
Expand DownExpand Up@@ -355,6 +356,14 @@ def test_reference_cycle(self):
type(t).refcyle = t
"""))

def test_replace_gc_tracked(self):
# Verify that __replace__ results are properly GC-tracked
time_struct = time.gmtime(0)
lst = []
replaced_struct = time_struct.__replace__(tm_year=lst)
lst.append(replaced_struct)

self.assertTrue(gc.is_tracked(replaced_struct))

if __name__ == "__main__":
unittest.main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fix GC tracking in ``structseq.__replace__()``.
1 change: 1 addition & 0 deletions Objects/structseq.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -445,6 +445,7 @@ structseq_replace(PyObject *op, PyObject *args, PyObject *kwargs)
}
}

_PyObject_GC_TRACK(result);
return (PyObject *)result;

error:
Expand Down
Loading