Skip to content

Commit 479ac5c

Browse files
authored
gh-115859: Fix test_type_inconsistency() when run multiple times (#116079)
This should fix the refleaks bots. (See #116062 (comment) .)
1 parent 3ea78fd commit 479ac5c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/test/test_capi/test_opt.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,13 @@ def testfunc(n):
893893
self.assertIn("_COMPARE_OP_STR", uops)
894894

895895
def test_type_inconsistency(self):
896-
def testfunc(n):
897-
for i in range(n):
898-
x = _test_global + _test_global
896+
ns = {}
897+
exec(textwrap.dedent("""
898+
def testfunc(n):
899+
for i in range(n):
900+
x = _test_global + _test_global
901+
"""), globals(), ns)
902+
testfunc = ns['testfunc']
899903
# Must be a real global else it won't be optimized to _LOAD_CONST_INLINE
900904
global _test_global
901905
_test_global = 0

0 commit comments

Comments
 (0)