Bug 995206 triggered me in trying the regular
expression given in PEP 263 for the encoding syntax.
This is the result (on Linux, with a failry up-to-date
Python):
Python 2.4a1+ (#1, Jul 19 2004, 08:51:40)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import re
>>> re.compile(r"coding[:=]\s*([\w-_.]+)")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/sjoerd/src/python/Lib/sre.py", line 179,
in compile
return _compile(pattern, flags)
File "/home/sjoerd/src/python/Lib/sre.py", line 230,
in _compile
raise error, v # invalid expression
sre_constants.error: bad character range
>>>
It seems to me that the PEP's regular expression should
be fixed (or re has a bug).
|