[registry] Stop using load_module_from_name

It as no benefit over __import__ and causes pb in some cases (eg not considering properly parent package's __path__).

Closes #6085650

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset7ebacaa38380
branchdefault
phasepublic
hiddenno
parent revision#63de39be70f2 Fix regression with datetime2ticks vs date object as argument
child revision#69d37ec8a2d1 [changelog] ensure ChangeLogEntry write unicode (closes #6213577), #c1f4fe8add2c [changelog] ensure ChangeLogEntry write unicode (closes #6213577)
files modified by this revision
logilab/common/registry.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1463660585 -7200
# Thu May 19 14:23:05 2016 +0200
# Node ID 7ebacaa383805ac6bd2787a8a38b8aac78043645
# Parent 63de39be70f20f18345cf0e13b154e935a99fa62
[registry] Stop using load_module_from_name

It as no benefit over __import__ and causes pb in some cases (eg not considering
properly parent package's __path__).

Closes #6085650

diff --git a/logilab/common/registry.py b/logilab/common/registry.py
@@ -718,11 +718,10 @@
1                      return True
2          return False
3 
4      def load_file(self, filepath, modname):
5          """ load registrable objects (if any) from a python file """
6 -        from logilab.common.modutils import load_module_from_name
7          if modname in self._loadedmods:
8              return
9          self._loadedmods[modname] = {}
10          mdate = self._mdate(filepath)
11          if mdate is None:
@@ -733,11 +732,11 @@
12          # set update time before module loading, else we get some reloading
13          # weirdness in case of syntax error or other error while importing the
14          # module
15          self._lastmodifs[filepath] = mdate
16          # load the module
17 -        module = load_module_from_name(modname)
18 +        module = __import__(modname, fromlist=modname.split('.')[:-1])
19          self.load_module(module)
20 
21      def load_module(self, module):
22          """Automatically handle module objects registration.
23