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.

Unsupported provider

classification
Title: 2to3 passes through string literal which causes SyntaxError in 3.x
Type: behavior Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Arfrever, benjamin.peterson, python-dev, serhiy.storchaka, vinay.sajip
Priority: normal Keywords: patch

Created on 2013-05-22 21:46 by vinay.sajip, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
2to3_escape_u-2.7.patch serhiy.storchaka, 2013-09-07 23:26 review
Messages (10)
msg189837 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2013-05-22 21:46
"""
This string contains DOMAIN\username, which is talking about Windows
and is a valid string in Python 2.x but not in 3.x. However, 2to3 passes
this string through unchanged, and it causes a SyntaxError when
interpreted by Python 3.x, because it contains what looks like a
truncated Unicode escape.
"""
msg189848 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-23 05:00
However r'DOMAIN\username' is valid in 3.x (if this is not a regular expression in 3.3+).

It would be good to emit a warning in Python 2 with -3 option. Or perhaps even emit a warning about any non-known escape in non-raw strings.
msg197199 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-09-07 23:26
Here is a patch against 2.7.

What is the policy about changing 2to3 in 3.x?
msg197200 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-09-07 23:29
You can change 2to3 in 3.x.
msg198853 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-02 17:15
Is the patch good to you Benjamin? I'm not very experienced in 2to3 machinery.
msg198870 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-10-02 20:34
That seems fine.
msg198887 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-03 09:13
New changeset 5e8de100f708 by Serhiy Storchaka in branch '2.7':
Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
http://hg.python.org/cpython/rev/5e8de100f708

New changeset 5950dd4cd9ef by Serhiy Storchaka in branch '3.3':
Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
http://hg.python.org/cpython/rev/5950dd4cd9ef

New changeset 7d3695937362 by Serhiy Storchaka in branch 'default':
Issue #18037: 2to3 now escapes '\u' and '\U' in native strings.
http://hg.python.org/cpython/rev/7d3695937362
msg199168 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2013-10-08 00:50
These revisions also introduced escaping of \u and \U in raw literals, which is incorrect.
It breaks e.g. Sphinx.
msg199226 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-08 18:09
New changeset c498d1090970 by Serhiy Storchaka in branch '2.7':
Issue #18037: Do not escape '\u' and '\U' in raw strings.
http://hg.python.org/cpython/rev/c498d1090970

New changeset acb2dacd0d24 by Serhiy Storchaka in branch '3.3':
Issue #18037: Do not escape '\u' and '\U' in raw strings.
http://hg.python.org/cpython/rev/acb2dacd0d24

New changeset a49d313a28ae by Serhiy Storchaka in branch 'default':
Issue #18037: Do not escape '\u' and '\U' in raw strings.
http://hg.python.org/cpython/rev/a49d313a28ae
msg199227 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-08 18:10
Thank you Arfrever.
History
Date User Action Args
2022-04-11 14:57:45adminsetgithub: 62237
2013-10-08 18:10:41serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg199227

stage: resolved
2013-10-08 18:09:27python-devsetmessages: + msg199226
2013-10-08 00:50:25Arfreversetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg199168

stage: resolved -> (no value)
2013-10-03 10:44:56serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-10-03 09:13:02python-devsetnosy: + python-dev
messages: + msg198887
2013-10-02 20:34:18benjamin.petersonsetmessages: + msg198870
2013-10-02 17:15:01serhiy.storchakasetmessages: + msg198853
2013-10-01 21:43:44serhiy.storchakasetassignee: serhiy.storchaka
2013-09-07 23:29:53benjamin.petersonsetmessages: + msg197200
2013-09-07 23:26:28serhiy.storchakasetfiles: + 2to3_escape_u-2.7.patch
versions: + Python 3.3, Python 3.4
messages: + msg197199

keywords: + patch
stage: patch review
2013-05-23 05:18:09Arfreversetnosy: + Arfrever
2013-05-23 05:00:25serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg189848
2013-05-22 21:46:44vinay.sajipcreate