Issue 15096: Drop support for the "ur" string prefix (original) (raw)

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

Messages (8)

msg163062 - (view)

Author: Alyssa 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🔞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 ).

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:

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:31

admin

set

github: 59301

2014-09-02 20:59:57

r.david.murray

link

issue22328 superseder

2012-06-20 09:24:48

christian.heimes

set

status: open -> closed
resolution: fixed
messages: +

stage: patch review -> resolved

2012-06-20 09🔞14

python-dev

set

nosy: + python-dev
messages: +

2012-06-19 21:43:43

christian.heimes

set

keywords: + needs review
files: + issue15096-2.patch
messages: +

stage: needs patch -> patch review

2012-06-19 20:52:39

christian.heimes

set

assignee: christian.heimes
messages: +

2012-06-19 20:17:14

georg.brandl

set

nosy: + georg.brandl
messages: +

2012-06-19 16:19:25

vinay.sajip

link

issue14973 superseder

2012-06-18 19:24:30

Arfrever

set

nosy: + Arfrever

2012-06-17 16:36:03

serhiy.storchaka

set

messages: +

2012-06-17 16:20:34

flox

set

nosy: + vinay.sajip

2012-06-17 16:16:16

flox

set

nosy: + aronacher, flox

2012-06-17 12:58:52

christian.heimes

set

files: + issue15096-1.patch

nosy: + christian.heimes
messages: +

keywords: + patch

2012-06-17 12:30:41

serhiy.storchaka

set

nosy: + serhiy.storchaka

2012-06-17 12:20:29

ezio.melotti

set

nosy: + ezio.melotti

2012-06-17 12🔞03

ncoghlan

set

priority: normal -> release blocker

2012-06-17 12:17:38

ncoghlan

create