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: ur'\u' not handled properly
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: jepler, lemburg, rhettinger
Priority: normal Keywords:

Created on 2002-07-26 16:05 by jepler, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ref2.diff rhettinger, 2002-08-05 05:53 Documentation patch
Messages (4)
msg11731 - (view) Author: Jeff Epler (jepler) Date: 2002-07-26 16:05
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.
msg11732 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2002-07-26 16:31
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.
msg11733 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-08-05 05:53
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.
msg11734 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-08-06 22:40
Logged In: YES 
user_id=80475

Jeff, thanks for the bug report.
Committed patch to ref2.tex version 1.40 and 1.34.6.3.
Closing bug.


History
Date User Action Args
2022-04-10 16:05:31adminsetgithub: 36941
2002-07-26 16:05:48jeplercreate