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

Chris Angelico rosuav at gmail.com
Tue Feb 24 11:58:55 CET 2015


On Tue, Feb 24, 2015 at 7:40 PM, M.-A. Lemburg <mal at egenix.com> wrote:
> I think the easiest way would be to tweak the error message
> output to indicate the real problem.
>
> At the moment, you get:
>
>>>> open('c:\test.txt')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> FileNotFoundError: [Errno 2] No such file or directory: 'c:\test.txt'
>
> which isn't helpful.

The problem isn't the cases where the file can't be found. Those can
be dealt with fairly easily, one way or another. The problem is much,
much earlier, when the student was using "c:\sample.txt" and
everything was working fine. Then he changed the code over to use his
own file instead of the provided sample, and at the same time,
switched from using open() to using csv.reader(open()), and moved all
the code into a function, and fixed three other bugs, and now it isn't
working. And he can't figure out why.

That's why I'd like "c:\sample.txt" to raise a warning.

Should I start writing up a PEP? Is that the way forward with this?

ChrisA


More information about the Python-Dev mailing list