aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/easy_install.py
diff options
context:
space:
mode:
authorJurko Gospodnetić <jurko.gospodnetic@pke.hr>2014-04-15 23:27:23 +0200
committerJurko Gospodnetić <jurko.gospodnetic@pke.hr>2014-04-15 23:27:23 +0200
commitcb4b1a9e751b10d63d91197934d1d8f8fff44be9 (patch)
tree7ef6b7f7593ccf822cf3bd536acdcfcfc71f63d9 /setuptools/command/easy_install.py
parent896fd3d8c7eec74766560559f095fe92e49ecfba (diff)
downloadexternal_python_setuptools-cb4b1a9e751b10d63d91197934d1d8f8fff44be9.tar.gz
external_python_setuptools-cb4b1a9e751b10d63d91197934d1d8f8fff44be9.tar.bz2
external_python_setuptools-cb4b1a9e751b10d63d91197934d1d8f8fff44be9.zip
clean up easy_install.uncache_zipdir() code & comments
--HG-- extra : rebase_source : 79778a670897cb92c17307f2535fcac6447e16b4
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-xsetuptools/command/easy_install.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 10176874..8c281590 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -1583,18 +1583,30 @@ def auto_chmod(func, arg, exc):
reraise(et, (ev[0], ev[1] + (" %s %s" % (func,arg))))
def uncache_zipdir(path):
- """Ensure that the importer caches dont have stale info for `path`"""
- from zipimport import _zip_directory_cache as zdc
- _uncache(path, zdc)
+ """
+ Remove any globally cached zip file related data for `path`
+
+ Stale zipimport.zipimporter objects need to be removed when a zip file is
+ replaced as they contain cached zip file directory information. If they are
+ asked to get data from their zip file, they will use that cached
+ information to calculate the data location in the zip file. This calculated
+ location may be incorrect for the replaced zip file, which may in turn
+ cause the read operation to either fail or return incorrect data.
+
+ Note we have no way to clear any local caches from here. That is left up to
+ whomever is in charge of maintaining that cache.
+
+ """
+ _uncache(path, zipimport._zip_directory_cache)
_uncache(path, sys.path_importer_cache)
def _uncache(path, cache):
if path in cache:
del cache[path]
else:
- path = normalize_path(path)
+ normalized_path = normalize_path(path)
for p in cache:
- if normalize_path(p)==path:
+ if normalize_path(p) == normalized_path:
del cache[p]
return