[issue30641] No way to specify "File name too long" error in except statement.

2017-06-13 Thread R. David Murray
R. David Murray added the comment: Since according to Eryk there's no way to have a reliable cross-platform exception class catching file name to long, I'm rejecting this feature request. -- resolution: -> rejected stage: -> resolved status: open -> closed ___

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread Eryk Sun
Eryk Sun added the comment: An exception specifically for ENAMETOOLONG would be limited to Unix systems. The Windows CRT defines ENAMETOOLONG but doesn't use it. Windows file systems do not return a specific status code for a filename that's too long. Per MS-FSA 2.1.5.1 [1], a request to open

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: I don't understand what you actually are requesting here. Are you requesting a way to tell whether or not the filename is too long? You've already been told that the way to do that is to check errno, and you say that you already knew that. exc.errno == errno

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread Max Staff
Max Staff added the comment: ...at least those are the only two ways that I can think of. -- ___ Python tracker ___ ___ Python-bugs-li

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread Max Staff
Max Staff added the comment: Yes I know about the errno. There would be two ways to resolve this: One way would be by introducing a new exception class which would be nice because it's almost impossible to reliably check the allowed filename length (except for trial and error) and I have quite

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: On Unix, you can simply check the errno value: >>> fn = "x" * 999 >>> try: open(fn, "r") ... except OSError as e: exc = e ... >>> exc.errno 36 >>> exc.errno == errno.ENAMETOOLONG True I don't know about Windows. -- ___

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread R. David Murray
R. David Murray added the comment: There appears to be an errno for file name too long, so I presume you are making a feature request for a new exception class. I believe Antoine tried to strike a balance between the utility of the sub-exceptions and their number, so you'll have to make an ar

[issue30641] No way to specify "File name too long" error in except statement.

2017-06-12 Thread Max Staff
New submission from Max Staff: There are different ways to catch exceptions of the type "OSError": By using "except OSError as e:" and then checking the errno or by using "except FileNotFoundError e:" or "except FileExistsError e:" or whatever error one wants to catch. There's no such way for