Skip to content

Commit 024d6bc

Browse files
committed
upip: install_pkg: Use try-finally to ensure opened socket always closed.
1 parent 1bfd389 commit 024d6bc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

upip/upip.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,12 @@ def install_pkg(pkg_spec, install_path):
173173
print("Installing %s %s from %s" % (pkg_spec, latest_ver, package_url))
174174
package_fname = op_basename(package_url)
175175
f1 = url_open(package_url)
176-
f2 = uzlib.DecompIO(f1, gzdict_sz)
177-
f3 = tarfile.TarFile(fileobj=f2)
178-
meta = install_tar(f3, install_path)
179-
f1.close()
176+
try:
177+
f2 = uzlib.DecompIO(f1, gzdict_sz)
178+
f3 = tarfile.TarFile(fileobj=f2)
179+
meta = install_tar(f3, install_path)
180+
finally:
181+
f1.close()
180182
del f3
181183
del f2
182184
gc.collect()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy