mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #22423: Fixed debugging output of the GROUPREF_EXISTS opcode in the re
module.
This commit is contained in:
parent
1a5426dbaf
commit
44dae8bde3
3 changed files with 54 additions and 22 deletions
|
@ -1203,16 +1203,33 @@ class ReTests(unittest.TestCase):
|
|||
self.assertEqual(m.group(2), "y")
|
||||
|
||||
def test_debug_flag(self):
|
||||
pat = r'(\.)(?:[ch]|py)(?(1)$|: )'
|
||||
with captured_stdout() as out:
|
||||
re.compile('foo', re.DEBUG)
|
||||
self.assertEqual(out.getvalue().splitlines(),
|
||||
['literal 102 ', 'literal 111 ', 'literal 111 '])
|
||||
re.compile(pat, re.DEBUG)
|
||||
dump = '''\
|
||||
subpattern 1
|
||||
literal 46
|
||||
subpattern None
|
||||
branch
|
||||
in
|
||||
literal 99
|
||||
literal 104
|
||||
or
|
||||
literal 112
|
||||
literal 121
|
||||
subpattern None
|
||||
groupref_exists 1
|
||||
at at_end
|
||||
else
|
||||
literal 58
|
||||
literal 32
|
||||
'''
|
||||
self.assertEqual(out.getvalue(), dump)
|
||||
# Debug output is output again even a second time (bypassing
|
||||
# the cache -- issue #20426).
|
||||
with captured_stdout() as out:
|
||||
re.compile('foo', re.DEBUG)
|
||||
self.assertEqual(out.getvalue().splitlines(),
|
||||
['literal 102 ', 'literal 111 ', 'literal 111 '])
|
||||
re.compile(pat, re.DEBUG)
|
||||
self.assertEqual(out.getvalue(), dump)
|
||||
|
||||
def test_keyword_parameters(self):
|
||||
# Issue #20283: Accepting the string keyword parameter.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue