[issue41737] Improper NotADirectoryError when opening a file under a fake directory

2020-09-08 Thread Danny Lin
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, this behavior

[issue41737] Improper NotADirectoryError when opening a file under a fake directory

2020-09-07 Thread Eryk Sun
Eryk Sun added the comment: > if NotADirectoryError should be raised, it should mention '/path/to/file' > rather then '/path/to/file/somename.txt'. POSIX specifies that C open() should set errno to ENOTDIR when an existing path prefix component is neither a directory nor a symlink to a

[issue41737] Improper NotADirectoryError when opening a file under a fake directory

2020-09-07 Thread Danny Lin
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, similar code: