Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!border3.nntp.ams.giganews.com!backlog3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; '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; 'elsewhere,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'insensitive': 0.16; 'used:': 0.16; 'passing': 0.19; 'work,': 0.20; '>>>': 0.22; 'to:name :python-list@python.org': 0.22; 'typical': 0.24; 'sort': 0.25; 'equivalent': 0.26; "doesn't": 0.30; 'errors': 0.30; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; 'file': 0.32; 'running': 0.33; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'useful': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'such': 0.63; 'happen': 0.63; 'anything.': 0.68; 'user,': 0.69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=NMN5vW63IDg9s7VSClaLnuWlFbucaOuKKGYEoHvrPW8=; b=F9kfWionSOxIYM3UPVYCUpxMp1U2BCFdK+focgP2fFKmy0Jy+zeYb+8jAB3JofMgBN Zqzdl4eVH3Y3iQwfPHYaayUKTpiNqX8+M6lqxSHvSD+RZ9G3wR2OvFUvQNOvgV5Yg5o9 BK9Ff1oK9EEOf6HS5lfYLTIsAHlKe754pyJNIniljCWLKY1nCzLeMcvaoKYc4ldPsrLn vmpN08WMVLtQsB2lzpWRcLWdzsSwA+bayapCDSmUlkP63gZX8082pmDw12QT/86UDwJx FEojBGhsgQqDX12qm45PGH9qwRjU426A+VNMNGBPWdB8XZdEneXbmMca3sp2p7FyYJuX Pdkw== MIME-Version: 1.0 X-Received: by 10.107.160.212 with SMTP id j203mr11103536ioe.43.1424658568822; Sun, 22 Feb 2015 18:29:28 -0800 (PST) Date: Mon, 23 Feb 2015 13:29:28 +1100 Subject: Unrecognized backslash escapes in string literals From: Chris Angelico To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424658578 news.xs4all.nl 2879 [2001:888:2000:d::a6]:59589 X-Complaints-To: abuse@xs4all.nl X-Original-Bytes: 3990 Xref: csiph.com comp.lang.python:86178 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