Skip to content
Snippets Groups Projects
Commit 252d2260c74e authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

demandimport: look for 'mod' suffix as alternative name for module reference

It's widely used in our codebase.
parent 63365e9621d6
No related merge requests found
......@@ -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)
......
......@@ -52,6 +52,9 @@
import re as fred
print("fred =", f(fred))
import re as remod
print("remod =", f(remod))
import sys as re
print("re =", f(re))
......@@ -59,6 +62,9 @@
print("fred.sub =", f(fred.sub))
print("fred =", f(fred))
remod.escape # use remod
print("remod =", f(remod))
print("re =", f(re))
print("re.stderr =", f(re.stderr))
print("re =", f(re))
......
......@@ -9,7 +9,8 @@
hgweb_mod = <unloaded module 'hgweb_mod'>
hgweb = <module 'mercurial.hgweb' from '?'>
fred = <unloaded module 're'>
remod = <unloaded module 're'>
re = <unloaded module 'sys'>
fred = <unloaded module 're'>
fred.sub = <function sub at 0x?>
fred = <proxied module 're'>
......@@ -12,7 +13,8 @@
re = <unloaded module 'sys'>
fred = <unloaded module 're'>
fred.sub = <function sub at 0x?>
fred = <proxied module 're'>
remod = <module 're' from '?'>
re = <unloaded module 'sys'>
re.stderr = <open file '<whatever>', mode 'w' at 0x?>
re = <proxied module 'sys'>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment