[Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

Ethan Furman ethan at stoneleaf.us
Tue Feb 24 18:46:50 CET 2015


On 02/24/2015 09:18 AM, Thomas Wouters wrote:
> On Tue, Feb 24, 2015 at 5:37 PM, Ethan Furman wrote:
>>
>>  - M.A.Lemburg's idea of changing the exception message in key places to make a successful
>>    backslash replace obvious
>>    (FileNotFoundError: [Errno 2] No such file or directory: 'c:[\t]est.txt' - warning: embedded escapes)
> 
> Any ideas on how this check could be implemented? How would it distinguish \t
> from an actual tab in the string literal, or "C:\x64-python" from "C:\d-python"...?

--> 'a  tab'
'a\ttab'
--> 'a\ttab'
'a\ttab'

So the phrase "embedded escapes" may not always be accurate, but will be something to search on, and will help explain
what is being seen.

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150224/47329726/attachment.sig>


More information about the Python-Dev mailing list