DateTime bug?
montanaro at tttech.com
montanaro at tttech.com
Wed Jan 23 05:32:37 EST 2002
Carsten> I'm using Python 2.2 with the eGenix MX extensions 2.0.3. It seems the
Carsten> DateTime module has a bug:
...
Carsten> sre_constants.error: redefinition of group name 'sign' as group
Carsten> 7; was group 3
The sre package was tightened up for 2.2 to raise an error if the same named
group was present more than once in a regular expression. Here's 2.1:
% python
Python 2.1.1 (#1, Dec 12 2001, 09:47:33)
[GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import re
>>> re.compile(r"(?P<g1>[ab])(?P<g1>[cd])")
<SRE_Pattern object at 0x8180d90>
and 2.2:
% python
Python 2.2+ (#45, Jan 8 2002, 20:30:28)
[GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import re
>>> import re
>>> re.compile(r"(?P<g1>[ab])(?P<g1>[cd])")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.2/sre.py", line 178, in compile
return _compile(pattern, flags)
File "/usr/local/lib/python2.2/sre.py", line 228, in _compile
raise error, v # invalid expression
sre_constants.error: redefinition of group name 'g1' as group 2; was group 1
Because of the way regular expressions were built up out of smaller
fragments, mx.DateTime frequently repeated the same named group within a
single regular expression. I believe Marc-André Lemburg has released a new
version that does not rely on this.
--
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
More information about the Python-list
mailing list