[Python-bugs-list] [ python-Bugs-587087 ] ur'\u' not handled properly

noreply@sourceforge.net noreply@sourceforge.net
Tue, 06 Aug 2002 14:53:01 -0700


Bugs item #587087, was opened at 2002-07-26 12:05
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=587087&group_id=5470

Category: Parser/Compiler
Group: Python 2.2
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Jeff Epler (jepler)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: ur'\u' not handled properly

Initial Comment:
according to
http://www.python.org/doc/current/ref/strings.html, no
\-escapes have a meaning inside raw strings.

However, \u seems to be interpreted:
>>> ur'\u'
UnicodeError: Unicode-Escape decoding error: truncated
\uXXXX
>>> ur'\u0100'
u'\u0100'

I would expect the values to be
u'\u'
u'\u0100'

Tested in 2.3a0 from <2 weeks ago and python 2.2.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-05 01:53

Message:
Logged In: YES 
user_id=80475

Documentation patch attached for Fred's approval.

If okay, re-assign back to Raymond for a commit and 
backport to 2.2.

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

Comment By: M.-A. Lemburg (lemburg)
Date: 2002-07-26 12:31

Message:
Logged In: YES 
user_id=38388

I suppose this is a documentation bug. According to PEP 100:

    u = ur'<raw-unicode-escape encoded Python string>'

    The 'raw-unicode-escape' encoding is defined as follows:

    - \uXXXX sequence represent the U+XXXX Unicode character
if and
      only if the number of leading backslashes is odd

    - all other characters represent themselves as Unicode
ordinal
      (e.g. 'b' -> U+0062)

Assigned to Fred.

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

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