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: Drop support for the "ur" string prefix
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: Arfrever, aronacher, christian.heimes, ezio.melotti, flox, georg.brandl, ncoghlan, python-dev, serhiy.storchaka, vinay.sajip
Priority: release blocker Keywords: needs review, patch

Created on 2012-06-17 12:17 by ncoghlan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue15096-1.patch christian.heimes, 2012-06-17 12:58 review
issue15096-2.patch christian.heimes, 2012-06-19 21:43 review
Messages (8)
msg163062 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-06-17 12:17
When PEP 414 restored support for explicit Unicode literals in Python 3, the "ur" string prefix was deemed to be a synonym for the "r" prefix.

However, "ur" in 2.x was only kinda-sorta-raw, since it still supported Unicode escapes:

$ python
Python 2.7.3 (default, Apr 30 2012, 21:18:11) 
[GCC 4.7.0 20120416 (Red Hat 4.7.0-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print(ur'\u03B3')
γ

By contrast, they really are raw strings in 3.x, because the default UTF-8 source code encoding allows arbitrary Unicode characters to be included directly in the literal:

$ ./python
Python 3.3.0a4+ (default:cfbf6aa5c9e3+, Jun 17 2012, 15:25:45) 
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> r"γ"
'γ'
>>> "\U000003B3"
'γ'
>>> r"\U000003B3"
'\\U000003B3'
>>> ur"\U000003B3"
'\\U000003B3'

Rather than reintroducing this weird legacy not-really-raw string behaviour, I'd prefer to revert this aspect of the PEP 414 changes completely.
msg163067 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-06-17 12:58
+1

Raw unicode strings are rarely used and it's easy to overcome the limitation. I've created a patch that disabled ur'' syntax, updates the docs and adds some tests for u'' syntax. 

I couldn't find any tests for the syntax ... shame on you! :)
msg163078 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-17 16:36
> I've created a patch that disabled ur'' syntax, updates the docs and adds some tests for u'' syntax. 

Don't forget tokenize module (see issue15054).
msg163214 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-06-19 20:17
If you commit this, please do so before beta1.
msg163221 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-06-19 20:52
I'll submit an updated patch tomorrow.
msg163223 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-06-19 21:43
New patch:

* corrected comment in Parser/tokenizer.c

* added test for ub"" and bu"" raising SyntaxError

* removed handling of ur"" from tokenize module

Serhiy, could you please review my changed to the tokenize module? I think I found all relevant places but I'm not absolutely sure.
msg163263 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-06-20 09:18
New changeset 8e47e9af826e by Christian Heimes in branch 'default':
Issue #15096: Drop support for the ur string prefix
http://hg.python.org/cpython/rev/8e47e9af826e
msg163264 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-06-20 09:24
Thanks for you review, Serhiy. I removed the last remains from test_tokenize and even found another missing sentence in the docs.
History
Date User Action Args
2022-04-11 14:57:31adminsetgithub: 59301
2014-09-02 20:59:57r.david.murraylinkissue22328 superseder
2012-06-20 09:24:48christian.heimessetstatus: open -> closed
resolution: fixed
messages: + msg163264

stage: patch review -> resolved
2012-06-20 09:18:14python-devsetnosy: + python-dev
messages: + msg163263
2012-06-19 21:43:43christian.heimessetkeywords: + needs review
files: + issue15096-2.patch
messages: + msg163223

stage: needs patch -> patch review
2012-06-19 20:52:39christian.heimessetassignee: christian.heimes
messages: + msg163221
2012-06-19 20:17:14georg.brandlsetnosy: + georg.brandl
messages: + msg163214
2012-06-19 16:19:25vinay.sajiplinkissue14973 superseder
2012-06-18 19:24:30Arfreversetnosy: + Arfrever
2012-06-17 16:36:03serhiy.storchakasetmessages: + msg163078
2012-06-17 16:20:34floxsetnosy: + vinay.sajip
2012-06-17 16:16:16floxsetnosy: + aronacher, flox
2012-06-17 12:58:52christian.heimessetfiles: + issue15096-1.patch

nosy: + christian.heimes
messages: + msg163067

keywords: + patch
2012-06-17 12:30:41serhiy.storchakasetnosy: + serhiy.storchaka
2012-06-17 12:20:29ezio.melottisetnosy: + ezio.melotti
2012-06-17 12:18:03ncoghlansetpriority: normal -> release blocker
2012-06-17 12:17:38ncoghlancreate