[issue11451] Raw string parsing fails with backslash as last character

Graham Wideman report at bugs.python.org
Wed Mar 9 11:49:45 CET 2011


New submission from Graham Wideman <initcontact at grahamwideman.com>:

This is a copy of issue 1271 because I couldn't find a way to reopen it.

So, repeating my comment here:

As it currently stands, backslash at end of string is prohibited, apparently in the interests of supposedly allowing backslash to escape quotes that might be embedded within the string. 

But the supposedly beneficial backslash-escaping-embedded quote behavior is broken because the backslash remains in the string.

Consider:
(a) We already have the ability to use either single or double quotes around the string which gives that chance to use the other quote within the string. 
(b) The "principle of least surprise" for raw string would be to have raw mean "Never Escape Anything"
(c) backslash on end of string is currently a trap waiting to happen for Windows paths.
So I think there is strong motivation to abandon the currently broken "backslash escapes quote" behavior and just let raw strings be totally raw.  Furthermore, it's hard to imagine that such a move would break anything.  (Famous last words, I know... but I challenge anyone to contrive such a scenario!)

----------
components: Interpreter Core
messages: 130443
nosy: QuantumTim, facundobatista, georg.brandl, gwideman
priority: normal
severity: normal
status: open
title: Raw string parsing fails with backslash as last character
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11451>
_______________________________________


More information about the Python-bugs-list mailing list