Eryk Sun added the comment:

The NT runtime API RtlDosPathNameToRelativeNtPathName_U_WithStatus returns an 
informative error code, STATUS_NAME_TOO_LONG (0xC0000106). This gets translated 
to the less information but still useful Windows code ERROR_PATH_NOT_FOUND 
(0x0003). The CRT error table reduces this to ENOENT, so it's not readily 
distinguishable from ERROR_FILE_NOT_FOUND (0x0002).

The associated Windows error is still available via GetLastError when wopen 
returns:

    ucrtbase!wopen+0x22:
    00007ffb`222b5702 c3              ret
    0:000> ?? @$teb->LastErrorValue
    unsigned long 3

Currently io.FileIO calls PyErr_SetFromErrnoWithFilenameObjects. It could check 
for ERROR_PATH_NOT_FOUND when errno is ENOENT. In this case it could use a 
custom error message such as "No such path or path exceeds the maximum allowed 
length".

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27729>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to