mirror of
https://github.com/python/cpython.git
synced 2025-08-19 08:11:46 +00:00
[3.12] gh-106510: Fix DEBUG output for atomic group (GH-106511) (GH-106548)
(cherry picked from commit 74ec02e949
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
48f58e0243
commit
60ade0cb29
3 changed files with 8 additions and 2 deletions
|
@ -114,7 +114,6 @@ class SubPattern:
|
||||||
self.width = None
|
self.width = None
|
||||||
|
|
||||||
def dump(self, level=0):
|
def dump(self, level=0):
|
||||||
nl = True
|
|
||||||
seqtypes = (tuple, list)
|
seqtypes = (tuple, list)
|
||||||
for op, av in self.data:
|
for op, av in self.data:
|
||||||
print(level*" " + str(op), end='')
|
print(level*" " + str(op), end='')
|
||||||
|
@ -136,6 +135,9 @@ class SubPattern:
|
||||||
if item_no:
|
if item_no:
|
||||||
print(level*" " + "ELSE")
|
print(level*" " + "ELSE")
|
||||||
item_no.dump(level+1)
|
item_no.dump(level+1)
|
||||||
|
elif isinstance(av, SubPattern):
|
||||||
|
print()
|
||||||
|
av.dump(level+1)
|
||||||
elif isinstance(av, seqtypes):
|
elif isinstance(av, seqtypes):
|
||||||
nl = False
|
nl = False
|
||||||
for a in av:
|
for a in av:
|
||||||
|
|
|
@ -2512,7 +2512,10 @@ ELSE
|
||||||
|
|
||||||
def test_atomic_group(self):
|
def test_atomic_group(self):
|
||||||
self.assertEqual(get_debug_out(r'(?>ab?)'), '''\
|
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)
|
0. INFO 4 0b0 1 2 (to 5)
|
||||||
5: ATOMIC_GROUP 11 (to 17)
|
5: ATOMIC_GROUP 11 (to 17)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Improve debug output for atomic groups in regular expressions.
|
Loading…
Add table
Add a link
Reference in a new issue