bpo-39327: Close file descriptors as soon as possible in shutil.rmtree (GH-31384)


It fixes the "Text File Busy" OSError when using 'rmtree' on a
windows-managed filesystem in via the VirtualBox shared folder
(and possible other scenarios like a windows-managed network file
system).
(cherry picked from commit b77158b4da449ec5b8f682816a79d004fd65ed07)

Co-authored-by: Lital Natan <litaln@gmail.com>
3 files changed