Skip to content

Commit a54a699

Browse files
gh-94808: Fix regex on exotic platforms (#98036)
The test failed on a buildbot because the pointer was only 7 hex characters. To be safe, I bumped it down to 3: 4 in case we have 32-bit platforms, and 3 in case the pointer is very small.
1 parent cb4615f commit a54a699

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Lib/test/test_unicode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,15 +2811,15 @@ def check_format(expected, format, *args):
28112811
# We cannot test the exact result,
28122812
# because it returns a hex representation of a C pointer,
28132813
# which is going to be different each time. But, we can test the format.
2814-
p_format_regex = r'^0x[a-zA-Z0-9]{8,}$'
2814+
p_format_regex = r'^0x[a-zA-Z0-9]{3,}$'
28152815
p_format1 = PyUnicode_FromFormat(b'%p', 'abc')
28162816
self.assertIsInstance(p_format1, str)
28172817
self.assertRegex(p_format1, p_format_regex)
28182818

28192819
p_format2 = PyUnicode_FromFormat(b'%p %p', '123456', b'xyz')
28202820
self.assertIsInstance(p_format2, str)
28212821
self.assertRegex(p_format2,
2822-
r'0x[a-zA-Z0-9]{8,} 0x[a-zA-Z0-9]{8,}')
2822+
r'0x[a-zA-Z0-9]{3,} 0x[a-zA-Z0-9]{3,}')
28232823

28242824
# Extra args are ignored:
28252825
p_format3 = PyUnicode_FromFormat(b'%p', '123456', None, b'xyz')

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,7 @@ TESTSUBDIRS= distutils/tests \
20382038
test/test_zoneinfo test/test_zoneinfo/data \
20392039
test/test_unittest test/test_unittest/testmock \
20402040
test/tracedmodules \
2041+
test/typinganndata \
20412042
test/xmltestdata test/xmltestdata/c14n-20 \
20422043
test/ziptestdata
20432044

0 commit comments

Comments
 (0)