From 3832384c88e0ecf924da28e1c90557a0b8132ed8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 16 Nov 2026 11:16:09 +0100 Subject: [PATCH 1/2] gh-162092: Fix test_check_interned() of test_capi Fix fresh_string() for Free Threaded build to make sure that the string is not interned. Co-authored-by: Maik Schulze --- Lib/test/test_capi/test_unicode.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_capi/test_unicode.py b/Lib/test/test_capi/test_unicode.py index 84303bc379cf13..1bd81c985e21e0 100644 --- a/Lib/test/test_capi/test_unicode.py +++ b/Lib/test/test_capi/test_unicode.py @@ -1883,7 +1883,9 @@ def test_check_interned(self): def fresh_string(text): # Create a new string object by decoding a bytes string. - return text.encode().decode() + # Add a suffix to make sure that it's not interned, even if + # the string in interned in the PYC file (Free Threading). + return (text + ' suffix').encode().decode() s = fresh_string('hello') self.assertEqual(check_interned(s), SSTATE_NOT_INTERNED) From be3e8bfd0e7383d9e8c130eeb0781399ac49475b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 16 Nov 2026 16:20:36 +0100 Subject: [PATCH 2/2] Apply suggestion from @vstinner --- Lib/test/test_capi/test_unicode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_capi/test_unicode.py b/Lib/test/test_capi/test_unicode.py index 1bd81c985e21e0..fe4e8e3b5046e6 100644 --- a/Lib/test/test_capi/test_unicode.py +++ b/Lib/test/test_capi/test_unicode.py @@ -1884,7 +1884,7 @@ def test_check_interned(self): def fresh_string(text): # Create a new string object by decoding a bytes string. # Add a suffix to make sure that it's not interned, even if - # the string in interned in the PYC file (Free Threading). + # the string is interned in the PYC file (Free Threading). return (text + ' suffix').encode().decode() s = fresh_string('hello')