[ python-Bugs-1243192 ] Incorrect documentation of re.UNICODE

SourceForge.net noreply at sourceforge.net
Mon Feb 20 14:12:58 CET 2006


Bugs item #1243192, was opened at 2005-07-22 16:20
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1243192&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Nik Haldimann (nhaldimann)
>Assigned to: Georg Brandl (gbrandl)
Summary: Incorrect documentation of re.UNICODE

Initial Comment:
The effects of the re.UNICODE flag are incorrectly
documented in the library reference. Currently it says
(Section 4.2.3):

<snip>
U
UNICODE
Make \w, \W, \b, and \B dependent on the Unicode
character properties database. New in version 2.0.
</snip>

But this flag in fact also affects \d, \D, \s, and \S
at least since Python 2.1 (I have checked 2.1.3 on
Linux, 2.2.3, 2.3.5 and 2.4 on OS X and the source of
_sre.c makes this obvious). Proof:

Python 2.4 (#1, Feb 13 2005, 18:29:12) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on
darwin
Type "help", "copyright", "credits" or "license" for
more information.
>>> import re
>>> not re.match(r"\d", u"\u0966")
True
>>> re.match(r"\d", u"\u0966", re.UNICODE)
<_sre.SRE_Match object at 0x36ee20>
>>> not re.match(r"\s", u"\u2001")
True
>>> re.match(r"\s", u"\u2001", re.UNICODE)
<_sre.SRE_Match object at 0x36ee20>

\u0966 is some Indian digit, \u2001 is an em space.

I propose to change the docs to:

<snip>
U
UNICODE
Make \w, \W, \b, \B, \d, \D, \s, and \S dependent on
the Unicode character properties database. New in
version 2.0.
</snip>

Maybe the documentation of \d, \D, \s, and \S in
section 2.4.1 of the library reference should also be
adapted.

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

Comment By: Georg Brandl (birkenfeld)
Date: 2005-08-02 10:30

Message:
Logged In: YES 
user_id=1188172

Thanks! Committed as Doc/lib/libre.tex r1.114, r1.112.2.2.

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

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


More information about the Python-bugs-list mailing list