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

Graham Wideman report at bugs.python.org
Wed Mar 9 11:44:22 CET 2011

Graham Wideman <initcontact at grahamwideman.com> added the comment:

(Not clear how to reopen this issue. Hopefully my change here does that.)

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

But the embedded quote scenario doesn't work because the backslash remains in the string.  So the current state of play is plain broken.  

(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 a trap waiting to happen for Windows users.
...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.

nosy: +gwideman
type:  -> behavior
versions: +Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 -Python 2.4

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list