diff .hgtags @ 33531:9cbbf9118c6c

demandimport: prefer loaded module over package attribute (issue5617) In general, the attribute of the same name is overwritten by executing an import statement. import a.b print(a.b.c) # 'c' of a/b/__init__.py from a.b.c import d print(a.b.c) # a/b/c.py However, this appears not true for the scenario described in the test case, and surprisingly, "from a.b.c import d" works even if "a.b.c" is not a module. This patch works around the problem by taking the right module from sys.modules if available.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 16 Jul 2017 17:38:39 +0900
parents 1f37b084e8e7
children 9e0fea06ae2c
line wrap: on
line diff