[Python-bugs-list] bad pos value on match object (PR#397)

jeremy@beopen.com jeremy@beopen.com
Thu, 13 Jul 2000 21:42:48 -0400 (EDT)


Full_Name: Jeremy Hylton
Version: CVS Thu Jul 13 21:43:09 EDT 2000
OS: 
Submission from: w042.z064000252.bwi-md.dsl.cnc.net (64.0.252.42)
Submitted by: jeremy


The pos attribute of a match object is supposed to match the value of
the optional pos argument passed to match or search.  The default
value of the argument is zero.  The current implementation sets pos to
be the start of the match instead.

This program demonstrates:

import re
buf = "abcdef"
rx = re.compile("b(c)")
mo = rx.search(buf)
print mo.pos, mo.endpos
print mo.start(1), mo.end(1)

bitdiddle:/tmp> python1.5 retest.py 
0 6
2 3
bitdiddle:/tmp> python retest.py 
1 6
2 3