Commit 2bc803d5 authored by Nicolas Dumazet's avatar Nicolas Dumazet

add a comment as to why we test the type of the returned object


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39761 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b0060570
...@@ -14,7 +14,9 @@ class DynamicModule(ModuleType): ...@@ -14,7 +14,9 @@ class DynamicModule(ModuleType):
if name == '__path__': if name == '__path__':
raise AttributeError('%s does not have __path__' % (self,)) raise AttributeError('%s does not have __path__' % (self,))
obj = self._factory(name) obj = self._factory(name)
if hasattr(obj, '__module__'): # _factory can return an instance, a constant, or a class
if isinstance(obj, type):
# if it's a class we want to set __module__
obj.__module__ = self.__name__ obj.__module__ = self.__name__
setattr(self, name, obj) setattr(self, name, obj)
return obj return obj
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment