diff -r 63365e9621d6 -r 252d2260c74e hgdemandimport/demandimportpy2.py --- a/hgdemandimport/demandimportpy2.py Mon May 01 14:26:56 2017 +0900 +++ b/hgdemandimport/demandimportpy2.py Fri Apr 28 23:46:16 2017 +0900 @@ -132,8 +132,11 @@ subload(mod, x) # Replace references to this proxy instance with the actual module. - if locals and locals.get(head) is self: - locals[head] = mod + if locals: + if locals.get(head) is self: + locals[head] = mod + elif locals.get(head + r'mod') is self: + locals[head + r'mod'] = mod for modname in modrefs: modref = sys.modules.get(modname, None)