diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-21 19:48:24 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-21 19:48:24 (GMT) |
| commit | 560c578d1da47d7cdf94a718b3d4b572cb74f77e (patch) | |
| tree | abc14fe214949cab74d7f30c528687df31ff4acb /Lib/sre_parse.py | |
| parent | 68df7c239d8d097fcb8a6f63734a5037d3b74854 (diff) | |
| parent | 44dae8bde36866c2e216991498a3a3f883b3c8f2 (diff) | |
| download | cpython-560c578d1da47d7cdf94a718b3d4b572cb74f77e.zip cpython-560c578d1da47d7cdf94a718b3d4b572cb74f77e.tar.gz cpython-560c578d1da47d7cdf94a718b3d4b572cb74f77e.tar.bz2 | |
Issue #22423: Fixed debugging output of the GROUPREF_EXISTS opcode in the re
module.
Diffstat (limited to 'Lib/sre_parse.py')
| -rw-r--r-- | Lib/sre_parse.py | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 3209ce0..b56d437 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -94,33 +94,45 @@ class SubPattern: self.data = data self.width = None def dump(self, level=0): - nl = 1 + nl = True seqtypes = (tuple, list) for op, av in self.data: - print(level*" " + op, end=' '); nl = 0 - if op == "in": + print(level*" " + op, end='') + if op == IN: # member sublanguage - print(); nl = 1 + print() for op, a in av: print((level+1)*" " + op, a) - elif op == "branch": - print(); nl = 1 - i = 0 - for a in av[1]: - if i > 0: + elif op == BRANCH: + print() + for i, a in enumerate(av[1]): + if i: print(level*" " + "or") - a.dump(level+1); nl = 1 - i = i + 1 + a.dump(level+1) + elif op == GROUPREF_EXISTS: + condgroup, item_yes, item_no = av + print('', condgroup) + item_yes.dump(level+1) + if item_no: + print(level*" " + "else") + item_no.dump(level+1) elif isinstance(av, seqtypes): + nl = False for a in av: if isinstance(a, SubPattern): - if not nl: print() - a.dump(level+1); nl = 1 + if not nl: + print() + a.dump(level+1) + nl = True else: - print(a, end=' ') ; nl = 0 + if not nl: + print(' ', end='') + print(a, end='') + nl = False + if not nl: + print() else: - print(av, end=' ') ; nl = 0 - if not nl: print() + print('', av) def __repr__(self): return repr(self.data) def __len__(self): |
