Commit 90a07913 authored by Fredrik Lundh's avatar Fredrik Lundh

- pedantic: make sure "python -t" doesn't complain...

parent df02d0b3
...@@ -98,7 +98,7 @@ def _subn(pattern, template, string, count=0): ...@@ -98,7 +98,7 @@ def _subn(pattern, template, string, count=0):
if callable(template): if callable(template):
filter = template filter = template
else: else:
template = sre_parse.parse_template(template, pattern) template = sre_parse.parse_template(template, pattern)
def filter(match, template=template): def filter(match, template=template):
return sre_parse.expand_template(template, match) return sre_parse.expand_template(template, match)
n = i = 0 n = i = 0
...@@ -109,11 +109,11 @@ def _subn(pattern, template, string, count=0): ...@@ -109,11 +109,11 @@ def _subn(pattern, template, string, count=0):
m = c.search() m = c.search()
if not m: if not m:
break break
b, e = m.span() b, e = m.span()
if i < b: if i < b:
append(string[i:b]) append(string[i:b])
append(filter(m)) append(filter(m))
i = e i = e
n = n + 1 n = n + 1
append(string[i:]) append(string[i:])
return string[:0].join(s), n return string[:0].join(s), n
...@@ -130,15 +130,15 @@ def _split(pattern, string, maxsplit=0): ...@@ -130,15 +130,15 @@ def _split(pattern, string, maxsplit=0):
m = c.search() m = c.search()
if not m: if not m:
break break
b, e = m.span() b, e = m.span()
if b == e: if b == e:
if i >= len(string): if i >= len(string):
break break
continue continue
append(string[i:b]) append(string[i:b])
if g and b != e: if g and b != e:
extend(m.groups()) extend(m.groups())
i = e i = e
n = n + 1 n = n + 1
append(string[i:]) append(string[i:])
return s return s
This diff is collapsed.
This diff is collapsed.
# FIXME: this is basically test_re.py, with a few # FIXME: this is basically test_re.py, with a few minor changes
import sys import sys
sys.path=['.']+sys.path sys.path=['.']+sys.path
...@@ -337,7 +337,7 @@ for t in tests: ...@@ -337,7 +337,7 @@ for t in tests:
print repr(repl)+' should be '+repr(expected) print repr(repl)+' should be '+repr(expected)
else: else:
print '=== Failed incorrectly', t print '=== Failed incorrectly', t
continue continue
# Try the match on a unicode string, and check that it # Try the match on a unicode string, and check that it
# still succeeds. # still succeeds.
...@@ -359,9 +359,9 @@ for t in tests: ...@@ -359,9 +359,9 @@ for t in tests:
if pattern[:2]!='\\B' and pattern[-2:]!='\\B': if pattern[:2]!='\\B' and pattern[-2:]!='\\B':
obj=sre.compile(pattern) obj=sre.compile(pattern)
result=obj.search(s, result.start(0), result.end(0)+1) result=obj.search(s, result.start(0), result.end(0)+1)
if result==None: if result==None:
print '=== Failed on range-limited match', t print '=== Failed on range-limited match', t
# Try the match with IGNORECASE enabled, and check that it # Try the match with IGNORECASE enabled, and check that it
# still succeeds. # still succeeds.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment