mirror of
https://github.com/python/cpython.git
synced 2025-08-09 03:19:15 +00:00
[3.12] gh-116401: Fix blocking os.fwalk() and shutil.rmtree() on opening a named pipe (GH-116421) (GH-116716)
(cherry picked from commit aa7bcf284f
)
This commit is contained in:
parent
9ef84b46db
commit
9caad1f99b
6 changed files with 113 additions and 8 deletions
|
@ -676,7 +676,7 @@ def _rmtree_safe_fd(topfd, path, onexc):
|
|||
continue
|
||||
if is_dir:
|
||||
try:
|
||||
dirfd = os.open(entry.name, os.O_RDONLY, dir_fd=topfd)
|
||||
dirfd = os.open(entry.name, os.O_RDONLY | os.O_NONBLOCK, dir_fd=topfd)
|
||||
dirfd_closed = False
|
||||
except OSError as err:
|
||||
onexc(os.open, fullname, err)
|
||||
|
@ -775,7 +775,7 @@ def rmtree(path, ignore_errors=False, onerror=None, *, onexc=None, dir_fd=None):
|
|||
onexc(os.lstat, path, err)
|
||||
return
|
||||
try:
|
||||
fd = os.open(path, os.O_RDONLY, dir_fd=dir_fd)
|
||||
fd = os.open(path, os.O_RDONLY | os.O_NONBLOCK, dir_fd=dir_fd)
|
||||
fd_closed = False
|
||||
except Exception as err:
|
||||
onexc(os.open, path, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue