-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
OS-macstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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:
cpython/Lib/test/test_pathlib.py
Lines 2865 to 2886 in 7ee3aca
| @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.
Metadata
Metadata
Assignees
Labels
OS-macstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error