Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
When the target is a named pipe, shutil.rmtree() gets stuck on opening it.
# Create a named pipeimportos,tempfilefilename=os.path.join(tempfile.mkdtemp())filename=os.path.join(tempfile.mkdtemp(),"namedpipe")os.mkfifo(filename)# Try to remove itimportshutilshutil.rmtree(filename)# <- This blocks indefinitely^CTraceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/usr/lib/python3.11/shutil.py",line725,inrmtreefd=os.open(path,os.O_RDONLY,dir_fd=dir_fd)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^KeyboardInterrupt
This seems to be caused byos.open() withos.O_RDONLY.
Line 745 in4637a1f
| fd=os.open(path,os.O_RDONLY,dir_fd=dir_fd) |
(This issue seems to exist on the main branch, IIUC)
Currently, it needs to check the file type and useos.remove() if it's a named pipe.
Should this be handled insideshutil.rmtree()?
CPython versions tested on:
3.11
Operating systems tested on:
macOS