Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c08cb04

Browse files
committed
the usual
1 parent 880066a commit c08cb04

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

Lib/dos-8x3/sre_comp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def fixup(literal, flags=flags):
3939
return _sre.getlower(literal, flags)
4040
else:
4141
emit(OPCODES[op])
42-
fixup = lambda x: x
42+
fixup = lambda x: x
4343
skip = len(code); emit(0)
4444
for op, av in av:
4545
emit(OPCODES[op])
@@ -118,7 +118,7 @@ def fixup(literal, flags=flags):
118118
elif op is AT:
119119
emit(OPCODES[op])
120120
if flags & SRE_FLAG_MULTILINE:
121-
emit(ATCODES[AT_MULTILINE[av]])
121+
emit(ATCODES[AT_MULTILINE.get(av, av)])
122122
else:
123123
emit(ATCODES[av])
124124
elif op is BRANCH:
@@ -203,7 +203,7 @@ def compile(p, flags=0):
203203
if type(p) in (type(""), type(u"")):
204204
import sre_parse
205205
pattern = p
206-
p = sre_parse.parse(p)
206+
p = sre_parse.parse(p, flags)
207207
else:
208208
pattern = None
209209

Lib/dos-8x3/sre_pars.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
# FIXME: should be 65535, but the arraymodule is still broken
2020
MAXREPEAT = 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

2526
SPECIAL_CHARS = ".\\[{()*+?^$|"
2627
REPEAT_CHARS = "*+?{"
@@ -30,7 +31,7 @@
3031
OCTDIGITS = tuple("01234567")
3132
HEXDIGITS = tuple("0123456789abcdefABCDEF")
3233

33-
WHITESPACE = string.whitespace
34+
WHITESPACE = tuple(string.whitespace)
3435

3536
ESCAPES = {
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

Comments
 (0)