aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-01-02 16:30:44 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-01-02 16:30:44 -0500
commitf81c6c36c062d40834cee8add4947c211e5e152c (patch)
tree4dd7ab48687616a39bc668ba75be306ee55cd602
parentb875143b79b2e2ac6d87496d699e82e8123b6e5e (diff)
downloadexternal_python_setuptools-f81c6c36c062d40834cee8add4947c211e5e152c.tar.gz
external_python_setuptools-f81c6c36c062d40834cee8add4947c211e5e152c.tar.bz2
external_python_setuptools-f81c6c36c062d40834cee8add4947c211e5e152c.zip
Extract variable for extant name. Add comment about the hack.
--HG-- branch : feature/issue-229
-rw-r--r--pkg_resources/extern/__init__.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg_resources/extern/__init__.py b/pkg_resources/extern/__init__.py
index 2d338426..5e81c0bb 100644
--- a/pkg_resources/extern/__init__.py
+++ b/pkg_resources/extern/__init__.py
@@ -38,11 +38,17 @@ class VendorImporter:
root, base, target = fullname.partition(self.root_name + '.')
for prefix in self.search_path:
try:
- __import__(prefix + target)
- mod = sys.modules[prefix + target]
+ extant = prefix + target
+ __import__(extant)
+ mod = sys.modules[extant]
sys.modules[fullname] = mod
+ # mysterious hack:
+ # Remove the reference to the extant package/module
+ # on later Python versions to cause relative imports
+ # in the vendor package to resolve the same modules
+ # as those going through this importer.
if sys.version_info > (3, 3):
- del sys.modules[prefix + target]
+ del sys.modules[extant]
return mod
except ImportError:
pass