Skip to content

Commit 98b78d2

Browse files
committed
Run gc.collect() twice in test_rename on Python 3.12
Recently, the conditional `gc.collect()` step for Python >= 3.12 in `TestSubmodule.test_rename` is often insufficient. This has mainly been seen in #2248. For example: https://github.com/gitpython-developers/GitPython/actions/runs/22864869684/job/66331124651?pr=2106#step:12:620 In principle, there can be situations with finalizers where a cycle is only collectable due to finalization that happened due to a previous collection. Therefore, there is occasionally a benefit to collecting twice. This does that, in the hope that it will help.
1 parent c0a3d5f commit 98b78d2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

test/test_submodule.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ def test_rename(self, rwdir):
10111011
# garbage collector detailed in https://github.com/python/cpython/issues/97922.)
10121012
if sys.platform == "win32" and sys.version_info >= (3, 12):
10131013
gc.collect()
1014+
gc.collect() # Some finalizer scenarios need two collections, at least in theory.
10141015

10151016
new_path = "renamed/myname"
10161017
assert sm.move(new_path).name == new_path

0 commit comments

Comments
 (0)