[3.13] gh-130957: Use sleeping_retry in test_free_reference (GH-130958) (#131091)

The weak reference may not be immediately dead.
(cherry picked from commit 1908115871)

Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-03-11 15:14:28 +01:00 committed by GitHub
parent a49f85a694
commit 98c7ae3f7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -128,4 +128,7 @@ def test_free_reference(self):
wr = weakref.ref(obj)
del obj
support.gc_collect() # For PyPy or other GCs.
self.assertIsNone(wr())
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
if wr() is None:
break