diff options
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r-- | Lib/sre_compile.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index d8d01ea..ef26e1c 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -197,10 +197,11 @@ def _compile(code, pattern, flags): else: emit(ATCODES[av]) elif op is BRANCH: - emit(OPCODES[op]) tail = [] for av in av[1]: + emit(OPCODES[op]) skip = len(code); emit(0) + emit(MAXCODE) # save mark _compile(code, av, flags) emit(OPCODES[JUMP]) tail.append(len(code)); emit(0) @@ -286,11 +287,18 @@ def _compile_info(code, pattern, flags): emit(OPCODES[FAILURE]) code[skip] = len(code) - skip +STRING_TYPES = [type("")] + +try: + STRING_TYPES.append(type(unicode(""))) +except NameError: + pass + def compile(p, flags=0): # internal: convert pattern list to internal format # compile, as necessary - if type(p) in (type(""), type(u"")): + if type(p) in STRING_TYPES: import sre_parse pattern = p p = sre_parse.parse(p, flags) @@ -308,6 +316,8 @@ def compile(p, flags=0): code.append(OPCODES[SUCCESS]) + # print code + # FIXME: <fl> get rid of this limitation! assert p.pattern.groups <= 100,\ "sorry, but this version only supports 100 named groups" |