Mercurial > cpython-lru_cache-weakref
diff Lib/importlib/_bootstrap.py @ 76081:a40cd5976215
If a module injects something into sys.modules as a side-effect of
importation, then respect that injection.
Discovered thanks to Lib/xml/parsers/expat.py injecting
xml.parsers.expat.errors and etree now importing that directly as a
module.
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Mon, 02 Apr 2012 20:33:56 -0400 |
| parents | e4a510317172 |
| children | c071af95772a |
line wrap: on
line diff
--- a/Lib/importlib/_bootstrap.py Mon Apr 02 12:17:59 2012 -0400 +++ b/Lib/importlib/_bootstrap.py Mon Apr 02 20:33:56 2012 -0400 @@ -927,6 +927,9 @@ if parent: if parent not in sys.modules: import_(parent) + # Crazy side-effects! + if name in sys.modules: + return sys.modules[name] # Backwards-compatibility; be nicer to skip the dict lookup. parent_module = sys.modules[parent] try:
