Skip to content
Prev Previous commit
Next Next commit
Handle further errors in finally: block
  • Loading branch information
barneygale committed May 31, 2024
commit 462cfc13ef85015804f6b0953506573c0ccfb554
6 changes: 5 additions & 1 deletion Lib/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,12 @@ def onexc(*args):
# Close any file descriptors still on the stack.
while stack:
func, fd, path, entry = stack.pop()
if func is os.close:
if func is not os.close:
continue
try:
os.close(fd)
except OSError as err:
onexc(os.close, path, err)
else:
if dir_fd is not None:
raise NotImplementedError("dir_fd unavailable on this platform")
Expand Down