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

2015-02-24 Thread Isaac Morland
On Tue, 24 Feb 2015, Ethan Furman wrote: On 02/24/2015 10:49 AM, Guido van Rossum wrote: On Tue, Feb 24, 2015 at 10:47 AM, Ethan Furman wrote: I can attest from my impoverished Windows programming days that looking at -- os.listdir('c:\temp') SomeErrorMessage about syntax 'c:\temp' is

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

2015-02-24 Thread Guido van Rossum
[Adding back python-dev] Actually, I wasn't proposing to change repr() -- my sentiments are similar to Isaac Morland's. Only the error message for the most basic file open() call should be tweaked. No solution is perfect -- but it's probably common enough for someone to create a file or folder

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

2015-02-24 Thread Terry Reedy
On 2/24/2015 1:14 PM, Guido van Rossum wrote: And I'd weigh the needs of users who know what they are doing somewhat higher than educating newbies through error messages. While newbies are most likely to try out open() with a string literal, in real programs that is rare, and filenames are

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

2015-02-24 Thread Greg Ewing
Chris Angelico wrote: 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

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

2015-02-24 Thread Greg Ewing
Thomas Wouters wrote: Trying to make the error messages more similar, or more identifying, may be a good idea (as long as they aren't misleading when people *meant* to use escape sequences in a string) It seems that Windows won't let you use control characters in filenames, so there is room

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

2015-02-24 Thread Joao S. O. Bueno
On 23 February 2015 at 18:39, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Serhiy Storchaka wrote: The problem is that the user don't know that he should read the documentation. It just find that his script works with C:\sample.txt, but doesn't work with D:\test.txt. He has no ideas what

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

2015-02-24 Thread Chris Angelico
On Tue, Feb 24, 2015 at 7:40 PM, M.-A. Lemburg m...@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

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

2015-02-24 Thread Stephen J. Turnbull
Chris Angelico writes: I don't mind how long the deprecation period is, as long as there can be an option to Python that makes a noisy warning. If that's OK with you and for the use case you explicitly described, though, a .bat file that runs a linter first might be the better option since

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

2015-02-24 Thread Ethan Furman
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

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

2015-02-24 Thread Guido van Rossum
I like the \x07 solution. On Tue, Feb 24, 2015 at 10:47 AM, Ethan Furman et...@stoneleaf.us wrote: 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

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

2015-02-24 Thread Guido van Rossum
TBH I think this will be a tough sell. I worry that an meme will emerge to make all string literals use raw mode, or worse, to deprecate non-raw string literals. I'm not sure how we'll get out of the whole conundrum, and I'm not in a hurry to see this in 3.5. -- --Guido van Rossum

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

2015-02-24 Thread Ethan Furman
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:

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

2015-02-24 Thread Ethan Furman
On 02/24/2015 09:44 AM, Guido van Rossum wrote: TBH I think this will be a tough sell. I worry that an meme will emerge to make all string literals use raw mode, or worse, to deprecate non-raw string literals. I'm not sure how we'll get out of the whole conundrum, and I'm not in a hurry to

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

2015-02-24 Thread Guido van Rossum
On Tue, Feb 24, 2015 at 10:00 AM, Ethan Furman et...@stoneleaf.us wrote: On 02/24/2015 09:44 AM, Guido van Rossum wrote: TBH I think this will be a tough sell. I worry that an meme will emerge to make all string literals use raw mode, or worse, to deprecate non-raw string literals. I'm

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

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 5:00 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: There is a wider context here, too: semantics of the backslash escape URL:https://en.wikipedia.org/wiki/Backslash#Usage commonly include “backslash followed by a character not otherwise mentioned will produce that

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

2015-02-24 Thread Ethan Furman
On 02/24/2015 01:35 PM, Guido van Rossum wrote: Actually, I wasn't proposing to change repr() -- my sentiments are similar to Isaac Morland's. Only the error message for the most basic file open() call should be tweaked. As are mine -- I just like to be thorough when discussing possibilities.

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

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 6:54 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Chris Angelico wrote: 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

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

2015-02-24 Thread Stephen J. Turnbull
Nick Coghlan writes: The linter developers don't have a decision making process that lets them pursue things like this on their own. I'm not suggesting that the linter developers do any such thing. I'm suggesting that users (specifically Chris) customize their preferred linters (most permit

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

2015-02-23 Thread Guido van Rossum
I think that's a bit too strong. This has been unquestionably valid, correct Python -- it was an intentional feature from the start. It may not have turned out great, but I think that before warning loudly about every instance of this we should have a silent deprecation (which you can turn into a

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

2015-02-23 Thread Brett Cannon
On Mon Feb 23 2015 at 10:55:23 AM Chris Angelico ros...@gmail.com wrote: On Tue, Feb 24, 2015 at 2:44 AM, Guido van Rossum gu...@python.org wrote: I think that's a bit too strong. This has been unquestionably valid, correct Python -- it was an intentional feature from the start. It may not

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

2015-02-23 Thread Chris Angelico
On Tue, Feb 24, 2015 at 2:44 AM, Guido van Rossum gu...@python.org wrote: I think that's a bit too strong. This has been unquestionably valid, correct Python -- it was an intentional feature from the start. It may not have turned out great, but I think that before warning loudly about every

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

2015-02-23 Thread Chris Angelico
On Tue, Feb 24, 2015 at 3:12 AM, Brett Cannon br...@python.org wrote: On Mon Feb 23 2015 at 10:55:23 AM Chris Angelico ros...@gmail.com wrote: On Tue, Feb 24, 2015 at 2:44 AM, Guido van Rossum gu...@python.org wrote: I think that's a bit too strong. This has been unquestionably valid,

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

2015-02-23 Thread Antoine Pitrou
On Mon, 23 Feb 2015 16:58:29 -0300 Joao S. O. Bueno jsbu...@python.org.br wrote: On 23 February 2015 at 16:47, Antoine Pitrou solip...@pitrou.net wrote: On Mon, 23 Feb 2015 09:29:09 -0800 Guido van Rossum gu...@python.org wrote: On Mon, Feb 23, 2015 at 9:01 AM, Ethan Furman

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

2015-02-23 Thread Nick Coghlan
On 24 February 2015 at 08:40, Nick Coghlan ncogh...@gmail.com wrote: On 24 February 2015 at 07:39, Mark Lawrence breamore...@yahoo.co.uk wrote: On 23/02/2015 21:27, Serhiy Storchaka wrote: On 23.02.15 21:58, Joao S. O. Bueno wrote: That happens all the time, and is this use case that should

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

2015-02-23 Thread Ethan Furman
On 02/23/2015 02:40 PM, Nick Coghlan wrote: - pep8 and pylint warnings as soon as a patch can be accepted - Py3kWarning in Python 2.7.x - DeprecationWarning in Python 3.5 - SyntaxWarning in Python 3.6 - SyntaxError in Python 3.7 +1 -- ~Ethan~ signature.asc Description: OpenPGP digital

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

2015-02-23 Thread Mark Lawrence
On 23/02/2015 21:27, Serhiy Storchaka wrote: On 23.02.15 21:58, Joao S. O. Bueno wrote: That happens all the time, and is this use case that should possibly be addressed here - maybe something as simple as adding a couple of paragraphs to different places in the documentation could mitigate the

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

2015-02-23 Thread Serhiy Storchaka
See topic Unrecognized backslash escapes in string literals in Python list [1]. I agree that this is a problem, especially for novices (but even experience users can make a typo). May be emit SyntaxWarning on unrecognized backslash escapes? An exception is already raised on invalid octal or