[Python-Dev] Turning on sre?

Guido van Rossum guido@python.org
Sun, 18 Jun 2000 15:47:22 -0500


> Before 1.6a3, should the sre module be turned on, replacing re?  That
> way it'll start getting tested; better we find problems sooner rather
> than later...

That would be nice.  If I replace re.py with "from sre import *" and
run test_re.py, I grt in trouble in the sub() test:

$ ./python ../Lib/test/test_re.py
Running tests on re.search and re.match
Running tests on re.sub
Traceback (most recent call last):
  File "../Lib/test/test_re.py", line 41, in ?
    assert re.sub(r'\d+', bump_num, '08.2 -2 23x99y') == '9.3 -3 24x100y'
  File "./../Lib/sre.py", line 35, in sub
    return _compile(pattern).sub(repl, string, count)
  File "./../Lib/sre.py", line 84, in _sub
    return _subn(pattern, template, string, count)[0]
  File "./../Lib/sre.py", line 114, in _subn
    return string[:0].join(s), n
TypeError: sequence item 0 not a string
$

It appears that the value of s is a list containing alternating zeros
and strings: [0, '.', 0, ' -', 0, ' ', 0, 'x', 0, 'y'].

No time to look into this further, but it could be a bug in sre._subn().

--Guido van Rossum (home page: http://www.python.org/~guido/)