Skip to content

Commit f62d1e9

Browse files
fix tests for refleak check mode
1 parent 8d24e30 commit f62d1e9

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Lib/test/test_free_threading/test_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from concurrent.futures import ThreadPoolExecutor
55
from threading import Thread
66
from unittest import TestCase
7-
7+
import sys
88
from test.support import import_helper, threading_helper
99

1010
_testinternalcapi = import_helper.import_module("_testinternalcapi")
@@ -184,7 +184,7 @@ def test_per_type_cache_concurrent_reads(self):
184184
class C:
185185
pass
186186

187-
names = [f"attr_{i}" for i in range(
187+
names = [sys.intern(f"attr_{i}") for i in range(
188188
_testinternalcapi._Py_TYPECACHE_MINSIZE * 4)]
189189
for name in names:
190190
setattr(C, name, name)

Lib/test/test_type_cache.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" Tests for the internal type cache in CPython. """
22
import dis
3+
import sys
34
import unittest
45
import warnings
56
from test import support
@@ -310,9 +311,10 @@ def test_lookup_on_static_type(self):
310311
# The cache for static types is stored on interpreter for isolation
311312
# between subinterpreters, test that cache works for them as well.
312313
self.type_cache_invalidate(int)
313-
self.assertEqual(self.type_cache_lookup(int, "bit_length")[0], 0)
314-
attr = int.bit_length
315-
hit, value, _ = self.type_cache_lookup(int, "bit_length")
314+
name = sys.intern("bit_length")
315+
self.assertEqual(self.type_cache_lookup(int, name)[0], 0)
316+
attr = getattr(int, name)
317+
hit, value, _ = self.type_cache_lookup(int, name)
316318
self.assertEqual(hit, 1)
317319
self.assertIs(value, attr)
318320

0 commit comments

Comments
 (0)