Closed
Description
Bug report
Bug description:
When the target is a named pipe, shutil.rmtree() gets stuck on opening it.
# Create a named pipe import os, tempfile filename = os.path.join(tempfile.mkdtemp()) filename = os.path.join(tempfile.mkdtemp(), "namedpipe") os.mkfifo(filename) # Try to remove it import shutil shutil.rmtree(filename) # <- This blocks indefinitely ^CTraceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.11/shutil.py", line 725, in rmtree fd = os.open(path, os.O_RDONLY, dir_fd=dir_fd) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyboardInterrupt
This seems to be caused by os.open()
with os.O_RDONLY
.
Line 745 in 4637a1f
(This issue seems to exist on the main branch, IIUC)
Currently, it needs to check the file type and use os.remove()
if it's a named pipe.
Should this be handled inside shutil.rmtree()
?
CPython versions tested on:
3.11
Operating systems tested on:
macOS