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

Ethan Furman ethan at stoneleaf.us
Tue Feb 24 19:47:10 CET 2015


On 02/24/2015 10:14 AM, Guido van Rossum wrote:

> This is about messages from failing file-open operations if the filename contains an escaped character? I'd go slow
> there too: here are a lot of places where files are opened and messages are printed, both in the C code and in the
> stdlib. I'm not sure I buy the argument that just echoing the repr() of the name back doesn't help -- the escapes in
> there are actually useful in case a filename containing garbage chars (or even a trailing space) was read from some
> other source.

I can attest from my impoverished Windows programming days that looking at

  --> os.listdir('c:\temp')
  SomeErrorMessage about syntax 'c:\temp'

is not very helpful.  There is zero visual indication that the \ and the t are one character, not two.  Changing that
error message to:

  SomeErrorMessage about syntax 'c:[\t]emp'

or

  SomeErrorMessage about syntax 'c:\x07emp'

or something that shouts out, "hey!  one character in this location!" would be a good thing.

--
~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/c49a447d/attachment.sig>


More information about the Python-Dev mailing list