[modutils] fix support for extend_path based namespace package when module is nested in a sub-package. Closes #177651

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset15df65e2dc2c
branchdefault
phasedraft
hiddenyes
parent revision#b488b5bd0277 [modutils] ensure file is closed, may cause pb depending on the interpreter (eg pypy). Closes #180876
child revision<not specified>
files modified by this revision
ChangeLog
modutils.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1381162362 -7200
# Mon Oct 07 18:12:42 2013 +0200
# Node ID 15df65e2dc2c4015c9710354121a45eaa8de8f08
# Parent b488b5bd0277375b640bbd494b736aa6433e07b7
[modutils] fix support for extend_path based namespace package when module is nested in a sub-package. Closes #177651

diff --git a/ChangeLog b/ChangeLog
@@ -1,14 +1,16 @@
1  ChangeLog for logilab.common
2  ============================
3 
4  --
5 -   * modutils: 
6 +   * modutils:
7       * don't propagate IOError when package's __init__.py file doesn't
8         exist (#174606)
9       * ensure file is closed, may cause pb depending on the interpreter, eg
10         pypy) (#180876)
11 +     * fix support for `extend_path` based nested namespace packages ;
12 +       Report and patch by John Johnson (#177651)
13 
14  2013-07-26  --  0.60.0
15      * configuration: rename option_name method into option_attrname (#140667)
16 
17      * deprecation: new DeprecationManager class (closes #108205)
diff --git a/modutils.py b/modutils.py
@@ -665,12 +665,12 @@
18                  path = [mp_filename]
19              else:
20                  if 'pkgutil' in data and 'extend_path' in data:
21                      # extend_path is called, search sys.path for module/packages
22                      # of this name see pkgutil.extend_path documentation
23 -                    path = [join(p, modname) for p in sys.path
24 -                            if isdir(join(p, modname))]
25 +                    path = [join(p, *imported) for p in sys.path
26 +                            if isdir(join(p, *imported))]
27                  else:
28                      path = [mp_filename]
29      return mtype, mp_filename
30 
31  def _is_python_file(filename):