Commit 6fbadf93 authored by Mikhail Golubev's avatar Mikhail Golubev
Browse files

PY-29471 Properly delete temp directory created by means of tempdir module

Previously in case of error pip run with runpy.run_module() terminated
the execution of the script abruptly with SystemExit and this cleanup
wasn't performed.

Normally it didn't happen though, since temp directory was created on
Java side in PyPackageManagerImpl.install() that was responsible for
its removal.

(cherry picked from commit d280c276)
parent 4ffd450c
Showing with 6 additions and 5 deletions
+6 -5
......@@ -143,11 +143,12 @@ def main():
rmdir = mkdtemp_ifneeded()
pkgs = sys.argv[2:]
do_install(pkgs)
if rmdir is not None:
import shutil
shutil.rmtree(rmdir)
try:
do_install(pkgs)
finally:
if rmdir is not None:
import shutil
shutil.rmtree(rmdir)
elif cmd == 'untar':
if len(sys.argv) < 2:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment