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: future unicode literals and r'\u'
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: backport 3.0-style \u/\U processing in raw strings when unicode_literals is imported from __future__
View: 2570
Assigned To: Nosy List: benjamin.peterson, flox, pooryorick, zhirsch
Priority: normal Keywords: patch

Created on 2009-03-08 20:11 by pooryorick, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
raw-unicode-literals.patch zhirsch, 2009-03-09 08:55
Messages (4)
msg83326 - (view) Author: Poor Yorick (pooryorick) * Date: 2009-03-08 20:11
from __future__ import unicode_literals
print(r'\u.bug')

SyntaxError: (unicode error) truncated \uXXXX
msg83327 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-03-08 20:17
This happens with unicode literals even without "from __future__ import
unicode_literals" because raw strings still have \u escapes interpreted.
This isn't true in 3.0, so it would be nice to disable it with
unicode_literals.
msg83363 - (view) Author: Zach Hirsch (zhirsch) Date: 2009-03-09 08:55
I've hit this, too, and it's annoyed me. So here's a patch against trunk
that should fix it. 

The idea is: whenever unicode_literals are turned on (or the -U command
line flag is passed), to convert r"\u" to "\u005c\u0075" and r"\U" to
"\u005c\u0055" for every string literal in the source file before
passing the string to PyUnicode_DecodeRawUnicodeEscape.
msg102084 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-04-01 11:44
Duplicate of #2570.
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49697
2010-04-01 11:45:37floxsetsuperseder: backport 3.0-style \u/\U processing in raw strings when unicode_literals is imported from __future__
2010-04-01 11:44:21floxsetstatus: open -> closed

nosy: + flox
messages: + msg102084

resolution: duplicate
2009-03-09 08:55:13zhirschsetfiles: + raw-unicode-literals.patch

nosy: + zhirsch
messages: + msg83363

keywords: + patch
2009-03-08 20:17:32benjamin.petersonsetpriority: normal
versions: + Python 2.7, - Python 2.6
nosy: + benjamin.peterson

messages: + msg83327

type: compile error -> enhancement
2009-03-08 20:11:31pooryorickcreate