diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-02 16:30:44 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-02 16:30:44 -0500 |
commit | 5fbb373ed91d4119323650b9651da04aadfe9ef3 (patch) | |
tree | 483c760ad02cd899f95063f7c2c57f2d9f981376 | |
parent | ec6c4f913a47acf5b4ed1bd5bda05c47f234088a (diff) | |
download | python-setuptools-bitbucket-5fbb373ed91d4119323650b9651da04aadfe9ef3.tar.gz |
Extract variable for extant name. Add comment about the hack.
-rw-r--r-- | pkg_resources/extern/__init__.py | 12 |
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 |