"Peter J. Holzer" <hjp-pyt...@hjp.at>: > POSIX specifies a number of error codes which can be returned by stat(): > > [EACCES] > Search permission is denied for a component of the path prefix. > [EIO] > An error occurred while reading from the file system. > [ELOOP] > A loop exists in symbolic links encountered during resolution of the > path argument. > [ENAMETOOLONG] > The length of a component of a pathname is longer than {NAME_MAX}. > [ENOENT] > A component of path does not name an existing file or path is an > empty string. > [ENOTDIR] > A component of the path prefix names an existing file that is > neither a directory nor a symbolic link to a directory, or the path > argument contains at least one non- <slash> character and ends with > one or more trailing <slash> characters and the last pathname > component names an existing file that is neither a directory nor a > symbolic link to a directory. > [EOVERFLOW] > The file size in bytes or the number of blocks allocated to the file > or the file serial number cannot be represented correctly in the > structure pointed to by buf. > > [...] > > Note that none of these covers "file name contains an illegal character" > for the simple reason that on POSIX systems there are no illegal > characters. > > So none of these is a good choice for the errno parameter of an OSError > to be thrown.
The natural errno value would be EINVAL, which is returned whenever a system call is invoked with an illegal argument. Marko -- https://mail.python.org/mailman/listinfo/python-list