Closed vector-of-bool closed 3 months ago
Describe the bug In the case of os.open with O_DIRECTORY, if the named file does not exist, it should fail with ENOENT and not ENOTDIR. From POSIX:
os.open
O_DIRECTORY
ENOENT
ENOTDIR
O_DIRECTORY: If path resolves to a non-directory file, fail and set errno to [ENOTDIR].
The issue appears to be the use of isdir() to check if the path is a directory, which simply returns False when the file does not exist.
isdir()
False
How To Reproduce
def do_open_dir_noent(): with pytest.raises(FileNotFoundError): os.open("this-path-does-not-name-an-existing-file", os.O_RDONLY | os.O_DIRECTORY) def test_open_dir_noent_realfs(): do_open_dir_noent() def test_open_dir_noent_fakefs(fs): do_open_dir_noent()
Your environment Please run the following in the environment where the problem happened and paste the output.
$ python -c "import platform; print(platform.platform())" Linux-6.7.6-arch1-1-x86_64-with-glibc2.39 $ python -c "import sys; print('Python', sys.version)" Python 3.11.7 (main, Jan 29 2024, 16:03:57) [GCC 13.2.1 20230801] $ python -c "from pyfakefs import __version__; print('pyfakefs', __version__)" pyfakefs 5.4.dev0 $ python -c "import pytest; print('pytest', pytest.__version__)" pytest 7.2.0
Describe the bug In the case of
os.open
withO_DIRECTORY
, if the named file does not exist, it should fail withENOENT
and notENOTDIR
. From POSIX:The issue appears to be the use of
isdir()
to check if the path is a directory, which simply returnsFalse
when the file does not exist.How To Reproduce
Your environment Please run the following in the environment where the problem happened and paste the output.