| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | import copy | |
| 2 | + import gc | ||
| 2 | 3 | import os | |
| 3 | 4 | import pickle | |
| 4 | 5 | import re | |
@@ -355,6 +356,14 @@ def test_reference_cycle(self): | |||
| 355 | 356 | type(t).refcyle = t | |
| 356 | 357 | """)) | |
| 357 | 358 | ||
| 359 | + def test_replace_gc_tracked(self): | ||
| 360 | + # Verify that __replace__ results are properly GC-tracked | ||
| 361 | + time_struct = time.gmtime(0) | ||
| 362 | + lst = [] | ||
| 363 | + replaced_struct = time_struct.__replace__(tm_year=lst) | ||
| 364 | + lst.append(replaced_struct) | ||
| 365 | + | ||
| 366 | + self.assertTrue(gc.is_tracked(replaced_struct)) | ||
| 358 | 367 | ||
| 359 | 368 | if __name__ == "__main__": | |
| 360 | 369 | unittest.main() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fix GC tracking in ``structseq.__replace__()``. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -445,6 +445,7 @@ structseq_replace(PyObject *op, PyObject *args, PyObject *kwargs) | |||
| 445 | 445 | } | |
| 446 | 446 | } | |
| 447 | 447 | ||
| 448 | + _PyObject_GC_TRACK(result); | ||
| 448 | 449 | return (PyObject *)result; | |
| 449 | 450 | ||
| 450 | 451 | error: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments