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 a file must fail with STATUS_OBJECT_NAME_INVALID 
if the name is invalid according to the spec in MS-FSCC 2.1.5 [2] (e.g. max 
component length cannot exceed 255 characters and may be less). This doesn't 
tell the caller why the filename is invalid. Anyway, for what it's worth, the 
Windows API translates this status code to ERROR_INVALID_NAME (0x007B), and the 
CRT in turn maps the latter to EINVAL.

Also, for versions prior to Windows 10, or Windows 10 without the 
LongPathsEnabled policy setting, the observed error is more commonly due to 
path preprocessing in user mode. In this case DOS paths are limited to MAX_PATH 
(260). The error depends on the called function -- e.g. CreateFileA vs 
SetCurrentDirectoryA, or calling the [A]NSI vs [W]ide-character version. It 
could be ERROR_PATH_NOT_FOUND (ENOENT), ERROR_FILENAME_EXCED_RANGE (ENOENT), or 
ERROR_INVALID_PARAMETER (EINVAL). 

[1]: https://msdn.microsoft.com/en-us/library/ff469536
[2]: https://msdn.microsoft.com/en-us/library/cc422524

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

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

Reply via email to