Skip to content

Commit

Permalink
pythongh-94808: Fix regex on exotic platforms (python#98036)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JelleZijlstra authored and mpage committed Oct 11, 2022
1 parent 5a71338 commit 6444029
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/test/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2811,15 +2811,15 @@ def check_format(expected, format, *args):
# We cannot test the exact result,
# because it returns a hex representation of a C pointer,
# which is going to be different each time. But, we can test the format.
p_format_regex = r'^0x[a-zA-Z0-9]{8,}$'
p_format_regex = r'^0x[a-zA-Z0-9]{3,}$'
p_format1 = PyUnicode_FromFormat(b'%p', 'abc')
self.assertIsInstance(p_format1, str)
self.assertRegex(p_format1, p_format_regex)

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

# Extra args are ignored:
p_format3 = PyUnicode_FromFormat(b'%p', '123456', None, b'xyz')
Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,7 @@ TESTSUBDIRS= distutils/tests \
test/test_zoneinfo test/test_zoneinfo/data \
test/test_unittest test/test_unittest/testmock \
test/tracedmodules \
test/typinganndata \
test/xmltestdata test/xmltestdata/c14n-20 \
test/ziptestdata

Expand Down

0 comments on commit 6444029

Please sign in to comment.