Skip to content

Commit 572ba2c

Browse files
committed
avoid Python 3.12+ breaking test labels starting with digits
1 parent 5eecdd9 commit 572ba2c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

parse_test_specification.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ def get_line_literals(stream, source_name, parameters, debug=0):
262262
if line.startswith("compiler_args="):
263263
line = re.sub(r"([ =])(\S+=\S+)", r"\1'\2'", line)
264264

265+
# tokenize.generate_tokens became more strict in Python 3.12
266+
# https://github.com/python/cpython/issues/105238
267+
#
268+
# This made some bare strings invalid in autotest.
269+
#
270+
# Most problematic test labels starting with a digit became invalid
271+
# if they were not valid numeric literal, e.g: 4_check
272+
#
273+
# as hack for backwards compatiblity we surround such labels with single-quotes
274+
line = re.sub(r'^(\d\w+)\s', r"'\1' ", line)
275+
265276
source_lines += line
266277
try:
267278
yield (

0 commit comments

Comments
 (0)