Commit f81c6c36 authored by Jason R. Coombs's avatar Jason R. Coombs

Extract variable for extant name. Add comment about the hack.

--HG--
branch : feature/issue-229
parent b875143b
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment