Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86182

Re: Unrecognized backslash escapes in string literals

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'explicitly': 0.05; 'string': 0.09; 'escape': 0.09; 'mask': 0.09; 'subject:string': 0.09; 'unrecognized': 0.09; 'way:': 0.09; 'python': 0.11; 'windows': 0.15; 'badly.': 0.16; 'cares': 0.16; 'different,': 0.16; 'elsewhere,': 0.16; 'insensitive': 0.16; 'literal,': 0.16; 'sequence,': 0.16; 'used:': 0.16; 'wrote:': 0.18; 'passing': 0.19; 'work,': 0.20; 'header:User-Agent:1': 0.23; 'typical': 0.24; 'sort': 0.25; "i've": 0.25; 'equivalent': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'errors': 0.30; 'especially': 0.30; 'program,': 0.31; '>>>>': 0.31; 'file': 0.32; 'says': 0.33; 'running': 0.33; "can't": 0.35; 'but': 0.35; 'there': 0.35; 'useful': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'full': 0.61; "you're": 0.61; 'such': 0.63; 'happen': 0.63; 'different': 0.65; 'charset:windows-1252': 0.65; 'anything.': 0.68; 'invalid': 0.68; 'received:74.208': 0.68; 'user,': 0.69; 'received:74.208.4.194': 0.84; 'warnings.': 0.84
Date Sun, 22 Feb 2015 21:47:27 -0500
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Unrecognized backslash escapes in string literals
References <CAPTjJmqx3s1a0LL4RLgVB1PsOfyF9ryy6nwHwOwrQs1Zx2Hd-Q@mail.gmail.com>
In-Reply-To <CAPTjJmqx3s1a0LL4RLgVB1PsOfyF9ryy6nwHwOwrQs1Zx2Hd-Q@mail.gmail.com>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:Oh9yRxc8CeMgz6aL85X5SYRwBGcvx5BMWatqSyebBmp Wyn+uBBfFokPAlkO7AogRnnWDruSLkEeJFeTpc0VpIRRjr/D3J bPGHICKlwRpvxnrHtsg3ehBh8er0nr8z31eDUen4rV4+tesDa1 Hek2hDk5aD2woy5x4Du6sOsaxsBg6Rp0ivkKECqfuXn60bj7Br I1vfL2MdW7WMrIZovJfjwzylmHLEnbsRXB8JU+FGe3lVprVlCO dtvZ6pB3Dwxi3YIAVTORyKzxeEzryN4iAJLABWHvPllGkSc0B9 KGoCqiYRP/QLD38405kjENaNI2/h3m/UM7tawXrSbMEeZ66ZNV zK7qJoo7a8ueGLKYsJxI=
X-UI-Out-Filterresults notjunk:1;
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.19044.1424659671.18130.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424659671 news.xs4all.nl 2863 [2001:888:2000:d::a6]:39459
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86182

Show key headers only | View raw


On 02/22/2015 09:29 PM, Chris Angelico wrote:
> In Python, unrecognized escape sequences are treated literally,
> without (as far as I can tell) any sort of warning or anything. This
> can mask bugs, especially when Windows path names are used:
>
>>>> 'C:\sqlite\Beginner.db'
> 'C:\\sqlite\\Beginner.db'
>>>> 'c:\sqlite\beginner.db'
> 'c:\\sqlite\x08eginner.db'
>
> To a typical Windows user, the two strings should be equivalent - case
> insensitive file names, who cares whether you say "Beginner" or
> "beginner"? But to Python, one of them will happen to work, the other
> will fail badly.
>
> Why is it that Python interprets them this way, and doesn't even give
> a warning? What happened to errors not passing silently? Or, looking
> at this the other way: Is there a way to enable such warnings/errors?
> I can't see one in 'python[3] -h', but if there's some way elsewhere,
> that would be a useful thing to recommend to people (I already
> recommend running Python 2 with -tt).
>
> ChrisA
>

I've long thought they should be errors, but in Python they're not even 
warnings.  It's one thing to let a user be sloppy on a shell's 
commandline, but in a program, if you have an invalid escape sequence, 
it should be an invalid string literal, full stop.

And Python doesn't even treat these invalid sequences the same (broken) 
way C does.  The documentation explicitly says it's different than C. 
If you're going to be different, at least be strict.

-- 
DaveA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Unrecognized backslash escapes in string literals Dave Angel <davea@davea.name> - 2015-02-22 21:47 -0500

csiph-web