Sitelet https://github.com/python/cpython/issues/98829#issue-1427846201
Skip to content

test_handling_bad_descriptor fails on macos 10.14 #98829

Description

@sobolevn

I am trying to run test_pathlib locally on my machine. One test fails:

» ./python.exe -m test -v test_pathlib -m test_handling_bad_descriptor
== CPython 3.12.0a1+ (heads/main:b27b57c6e4, Oct 28 2022, 20:34:51) [Clang 11.0.0 (clang-1100.0.33.16)]
== macOS-10.14.6-x86_64-i386-64bit little-endian
== cwd: /Users/sobolev/Desktop/cpython/build/test_python_5120æ
== CPU count: 4
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 1.86 Run tests sequentially
0:00:00 load avg: 1.86 [1/1] test_pathlib
test_handling_bad_descriptor (test.test_pathlib.PosixPathTest.test_handling_bad_descriptor) ... ERROR

======================================================================
ERROR: test_handling_bad_descriptor (test.test_pathlib.PosixPathTest.test_handling_bad_descriptor)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_pathlib.py", line 2869, in test_handling_bad_descriptor
    file_descriptors = list(pathlib.Path('/dev/fd').rglob("*"))[3:]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/pathlib.py", line 894, in rglob
    for p in selector.select_from(self):
  File "/Users/sobolev/Desktop/cpython/Lib/pathlib.py", line 334, in _select_from
    for p in successor_select(starting_point, is_dir, exists, scandir):
  File "/Users/sobolev/Desktop/cpython/Lib/pathlib.py", line 279, in _select_from
    with scandir(parent_path) as scandir_it:
         ^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/pathlib.py", line 864, in _scandir
    return os.scandir(self)
           ^^^^^^^^^^^^^^^^
NotADirectoryError: [Errno 20] Not a directory: '/dev/fd/36'

----------------------------------------------------------------------
Ran 1 test in 0.015s

Here's how it is defined:

@unittest.skipIf(sys.platform != "darwin",
"Bad file descriptor in /dev/fd affects only macOS")
def test_handling_bad_descriptor(self):
try:
file_descriptors = list(pathlib.Path('/dev/fd').rglob("*"))[3:]
if not file_descriptors:
self.skipTest("no file descriptors - issue was not reproduced")
# Checking all file descriptors because there is no guarantee
# which one will fail.
for f in file_descriptors:
f.exists()
f.is_dir()
f.is_file()
f.is_symlink()
f.is_block_device()
f.is_char_device()
f.is_fifo()
f.is_socket()
except OSError as e:
if e.errno == errno.EBADF:
self.fail("Bad file descriptor not handled.")
raise

My macos version: 10.14.x
Python is built with: ./configure --with-pydebug && make

Looks like something is off, I will try to investigate and send a PR.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

OS-macstdlibStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions