Skip to content

Commit 52c001d

Browse files
aiskvstinner
authored andcommitted
pythongh-108963: using random to generate unique string in sys.intern test (python#109491)
(cherry picked from commit 44b1e4e)
1 parent 8811f3d commit 52c001d

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Lib/test/test_sys.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import locale
55
import operator
66
import os
7+
import random
78
import struct
89
import subprocess
910
import sys
@@ -19,10 +20,6 @@
1920
import warnings
2021

2122

22-
# count the number of test runs, used to create unique
23-
# strings to intern in test_intern()
24-
INTERN_NUMRUNS = 0
25-
2623
DICT_KEY_STRUCT_FORMAT = 'n2BI2n'
2724

2825
class DisplayHookTest(unittest.TestCase):
@@ -685,10 +682,8 @@ def test_43581(self):
685682
self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)
686683

687684
def test_intern(self):
688-
global INTERN_NUMRUNS
689-
INTERN_NUMRUNS += 1
690685
self.assertRaises(TypeError, sys.intern)
691-
s = "never interned before" + str(INTERN_NUMRUNS)
686+
s = "never interned before" + str(random.randrange(0, 10**9))
692687
self.assertTrue(sys.intern(s) is s)
693688
s2 = s.swapcase().swapcase()
694689
self.assertTrue(sys.intern(s2) is s)

0 commit comments

Comments
 (0)