mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
[3.11] gh-116401: Fix blocking os.fwalk() and shutil.rmtree() on opening a named pipe (GH-116421) (GH-116717)
(cherry picked from commit aa7bcf284f
)
This commit is contained in:
parent
5bd350709d
commit
4a73637966
6 changed files with 113 additions and 8 deletions
|
@ -467,7 +467,7 @@ if {open, stat} <= supports_dir_fd and {scandir, stat} <= supports_fd:
|
|||
# lstat()/open()/fstat() trick.
|
||||
if not follow_symlinks:
|
||||
orig_st = stat(top, follow_symlinks=False, dir_fd=dir_fd)
|
||||
topfd = open(top, O_RDONLY, dir_fd=dir_fd)
|
||||
topfd = open(top, O_RDONLY | O_NONBLOCK, dir_fd=dir_fd)
|
||||
try:
|
||||
if (follow_symlinks or (st.S_ISDIR(orig_st.st_mode) and
|
||||
path.samestat(orig_st, stat(topfd)))):
|
||||
|
@ -516,7 +516,7 @@ if {open, stat} <= supports_dir_fd and {scandir, stat} <= supports_fd:
|
|||
assert entries is not None
|
||||
name, entry = name
|
||||
orig_st = entry.stat(follow_symlinks=False)
|
||||
dirfd = open(name, O_RDONLY, dir_fd=topfd)
|
||||
dirfd = open(name, O_RDONLY | O_NONBLOCK, dir_fd=topfd)
|
||||
except OSError as err:
|
||||
if onerror is not None:
|
||||
onerror(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue