1919# FIXME: should be 65535, but the arraymodule is still broken
2020MAXREPEAT = 32767
2121
22- # FIXME: same here
23- CHARMASK = 0x7fff
22+ # FIXME: might change in 2.0 final. but for now, this seems
23+ # to be the best way to be compatible with 1.5.2
24+ CHARMASK = 0xff
2425
2526SPECIAL_CHARS = ".\\ [{()*+?^$|"
2627REPEAT_CHARS = "*+?{"
3031OCTDIGITS = tuple ("01234567" )
3132HEXDIGITS = tuple ("0123456789abcdefABCDEF" )
3233
33- WHITESPACE = string .whitespace
34+ WHITESPACE = tuple ( string .whitespace )
3435
3536ESCAPES = {
3637 r"\a" : (LITERAL , 7 ),
@@ -295,7 +296,7 @@ def _branch(pattern, items):
295296 subpattern .append ((BRANCH , (None , items )))
296297 return subpattern
297298
298- def _parse (source , state , flags = 0 ):
299+ def _parse (source , state ):
299300
300301 # parse regular expression pattern into an operator list.
301302
@@ -467,7 +468,7 @@ def _parse(source, state, flags=0):
467468 char = source .get ()
468469 b = []
469470 while 1 :
470- p = _parse (source , state , flags )
471+ p = _parse (source , state )
471472 if source .next == ")" :
472473 if b :
473474 b .append (p )
@@ -494,7 +495,7 @@ def _parse(source, state, flags=0):
494495 else :
495496 group = state .getgroup (name )
496497 while 1 :
497- p = _parse (source , state , flags )
498+ p = _parse (source , state )
498499 if source .match (")" ):
499500 if b :
500501 b .append (p )
@@ -531,9 +532,10 @@ def parse(pattern, flags=0):
531532 # parse 're' pattern into list of (opcode, argument) tuples
532533 source = Tokenizer (pattern )
533534 state = State ()
535+ state .flags = flags
534536 b = []
535537 while 1 :
536- p = _parse (source , state , flags )
538+ p = _parse (source , state )
537539 tail = source .get ()
538540 if tail == "|" :
539541 b .append (p )
@@ -616,9 +618,9 @@ def expand_template(template, match):
616618 a = p .append
617619 sep = match .string [:0 ]
618620 if type (sep ) is type ("" ):
619- char = chr
621+ char = chr
620622 else :
621- char = unichr
623+ char = unichr
622624 for c , s in template :
623625 if c is LITERAL :
624626 a (char (s ))
0 commit comments