From e375c69d43ac5dd76552a283bf86341e40061aaa Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 11 Apr 2014 06:24:10 +0300 Subject: [PATCH] re-pcre: search(): Implement pos arg support. --- re-pcre/re.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/re-pcre/re.py b/re-pcre/re.py index e4ad70db..3632434c 100644 --- a/re-pcre/re.py +++ b/re-pcre/re.py @@ -54,12 +54,12 @@ class PCREPattern: self.obj = compiled_ptn def search(self, s, pos=0, endpos=-1, _flags=0): - assert pos == 0 and endpos == -1 + assert endpos == -1, "pos: %d, endpos: %d" % (pos, endpos) buf = bytes(4) pcre_fullinfo(self.obj, None, PCRE_INFO_CAPTURECOUNT, buf) cap_count = int.from_bytes(buf) ov = array.array('i', [0, 0, 0] * (cap_count + 1)) - num = pcre_exec(self.obj, None, s, len(s), 0, _flags, ov, len(ov)) + num = pcre_exec(self.obj, None, s, len(s), pos, _flags, ov, len(ov)) if num == -1: # No match return None