re-pcre: Add dummy pos/endpos args to search()/match().

asyncio-segfault
Paul Sokolovsky 2014-04-11 06:20:36 +03:00
rodzic 9ad8f7090d
commit 9592480266
1 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -47,7 +47,8 @@ class PCREPattern:
def __init__(self, compiled_ptn): def __init__(self, compiled_ptn):
self.obj = compiled_ptn self.obj = compiled_ptn
def search(self, s, _flags=0): def search(self, s, pos=0, endpos=-1, _flags=0):
assert pos == 0 and endpos == -1
buf = bytes(4) buf = bytes(4)
pcre_fullinfo(self.obj, None, PCRE_INFO_CAPTURECOUNT, buf) pcre_fullinfo(self.obj, None, PCRE_INFO_CAPTURECOUNT, buf)
cap_count = int.from_bytes(buf) cap_count = int.from_bytes(buf)
@ -58,8 +59,8 @@ class PCREPattern:
return None return None
return PCREMatch(s, num, ov) return PCREMatch(s, num, ov)
def match(self, s): def match(self, s, pos=0, endpos=-1):
return self.search(s, PCRE_ANCHORED) return self.search(s, pos, endpos, PCRE_ANCHORED)
def sub(self, repl, s): def sub(self, repl, s):
if not callable(repl): if not callable(repl):