Danny Lin added the comment:
It should be emphasized that it may happen on a **file operation**... So at
least be something like: "On some platforms, it may also be raised if a file
operation involves an attempt to open or traverse a non-directory file as if it
were a dire
Danny Lin added the comment:
@Andrei Kulakov: That statement is mainly for illustration that such behavior
may vary across platforms. I use a rather vague statement as I'm not totally
sure it applies if (and only if) running on POSIX. A more accurate statement is
welcome as long as
Danny Lin added the comment:
@Andrei Kulakov: I was commenting on the previous version. The revised version
(f2ae30b0de3c4ba1f16fc2a430cf22b447c062ed) seems ok to me.
Another question: would it be better if we add "on some platforms" for the part
that the error may raise on a file
Danny Lin added the comment:
> I've put up a PR that expands the docs for NotADirectoryError here:
> https://github.com/python/cpython/pull/27471/files
Thank you.
Wouldn't it be more clear if an example is provided? Like:
(e.g. `/path/to` does not exist when running `ope
Danny Lin added the comment:
> Really? It's not obvious that finding a file would involve directory
> operations?
Not in some senses, and that's possibly why Windows does not raise
NotADirectoryError in such case.
I agree that it's a platform-specific implementation d
Danny Lin added the comment:
I don't think a general developer would expect that
open('/path/to/file/somename.txt') implies a directory operation, and it also
doesn't on Windows.
I suggest that a further notice be added to NotADirectoryError, such as:
Raised when a
Danny Lin added the comment:
By writing "except FileNotFoundError:", the intention is to catch an error when
the file being opened is not found, and don't catch an error for other cases,
such as an existing file without adequate permission. Writing "except OSError:&quo
Danny Lin added the comment:
It doesn't seem so... In Python 3.8.5 this code is still seen in mimetypes.py
(line 492-504):
'.bmp': 'image/bmp',
'.gif': 'image/gif',
'.ief': 'image/ief',
Danny Lin added the comment:
I'm not so familiar about the spec. If such behavior is confirmed due to
implementation difference across OSes, and it's also not desirable to change
the mapping of the OS error to Python exception, we can simplify left it as-is.
However, thi
New submission from Danny Lin :
On Windows, command "python -m mimetypes foo.zip" outputs "type:
application/x-zip-compressed encoding: None", while it's "type: application/zip
encoding: None" on Linux.
According to the mimetype.py in CPython source
New submission from Danny Lin :
On Linux (tested on Ubuntu 16.04), if "/path/to/file" is an existing file, the
code:
open('/path/to/file/somename.txt')
raises NotADirectoryError: [Errno 20] Not a directory:
'/path/to/file/somename.txt'
On Windows, simila
11 matches
Mail list logo