Fix a scoping issue where an UnboundLocalError was triggered if a

lazy-loaded module was already in sys.modules.
This commit is contained in:
Brett Cannon 2016-06-25 10:47:53 -07:00
parent 559ad5d401
commit e92dc9c23d
3 changed files with 18 additions and 4 deletions

View file

@ -241,7 +241,7 @@ class _LazyModule(types.ModuleType):
if id(self) != id(sys.modules[original_name]):
msg = ('module object for {!r} substituted in sys.modules '
'during a lazy load')
raise ValueError(msg.format(original_name))
raise ValueError(msg.format(original_name))
# Update after loading since that's what would happen in an eager
# loading situation.
self.__dict__.update(attrs_updated)