diff options
-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 |