[ python-Bugs-995522 ] PEP 263 regular expression fails

SourceForge.net noreply at sourceforge.net
Wed Jul 21 23:23:30 CEST 2004


Bugs item #995522, was opened at 2004-07-21 16:52
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=995522&group_id=5470

Category: Documentation
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Sjoerd Mullender (sjoerd)
>Assigned to: A.M. Kuchling (akuchling)
Summary: PEP 263 regular expression fails

Initial Comment:
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).


----------------------------------------------------------------------

>Comment By: A.M. Kuchling (akuchling)
Date: 2004-07-21 17:23

Message:
Logged In: YES 
user_id=11375

Fix committed; closing.


----------------------------------------------------------------------

Comment By: A.M. Kuchling (akuchling)
Date: 2004-07-21 17:22

Message:
Logged In: YES 
user_id=11375

Swap the \w and - in the second range, giving [-\w_.].  I'll
fix the PEP.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=995522&group_id=5470


More information about the Python-bugs-list mailing list