[3.11] gh-106510: Fix DEBUG output for atomic group (GH-106511) (GH-106549)

(cherry picked from commit 74ec02e949)
This commit is contained in:
Miss Islington (bot) 2023-07-08 05:15:22 -07:00 committed by GitHub
parent 44c335e47d
commit 2d037fb406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -114,7 +114,6 @@ def __init__(self, state, data=None):
self.width = None
def dump(self, level=0):
nl = True
seqtypes = (tuple, list)
for op, av in self.data:
print(level*" " + str(op), end='')
@ -136,6 +135,9 @@ def dump(self, level=0):
if item_no:
print(level*" " + "ELSE")
item_no.dump(level+1)
elif isinstance(av, SubPattern):
print()
av.dump(level+1)
elif isinstance(av, seqtypes):
nl = False
for a in av:

View File

@ -2533,7 +2533,10 @@ def test_debug_flag(self):
def test_atomic_group(self):
self.assertEqual(get_debug_out(r'(?>ab?)'), '''\
ATOMIC_GROUP [(LITERAL, 97), (MAX_REPEAT, (0, 1, [(LITERAL, 98)]))]
ATOMIC_GROUP
LITERAL 97
MAX_REPEAT 0 1
LITERAL 98
0. INFO 4 0b0 1 2 (to 5)
5: ATOMIC_GROUP 11 (to 17)

View File

@ -0,0 +1 @@
Improve debug output for atomic groups in regular expressions.