This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PEP 263 regular expression fails
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, sjoerd
Priority: normal Keywords:

Created on 2004-07-21 20:52 by sjoerd, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg21748 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2004-07-21 20:52
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).
msg21749 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-07-21 21:22
Logged In: YES 
user_id=11375

Swap the \w and - in the second range, giving [-\w_.].  I'll
fix the PEP.
msg21750 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-07-21 21:23
Logged In: YES 
user_id=11375

Fix committed; closing.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40615
2004-07-21 20:52:04sjoerdcreate