Fix test breakage in modutils with python 3

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset62e014ec3b53
branchdefault
phasepublic
hiddenno
parent revision#9a8f910ac6f9 [configuration] Fix multi-line strings handling
child revision#2425b66aad66 [pkg] Version 1.3.0
files modified by this revision
logilab/common/modutils.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1479303965 -3600
# Wed Nov 16 14:46:05 2016 +0100
# Node ID 62e014ec3b530cfcb97dd9d6c0611b44425fd5b7
# Parent 9a8f910ac6f98b3f4aa44f039ca0ba1104f8b4a5
Fix test breakage in modutils with python 3

diff --git a/logilab/common/modutils.py b/logilab/common/modutils.py
@@ -652,11 +652,13 @@
1      # pkg_resources support (aka setuptools namespace packages)
2      if (_is_namespace(modpath[0]) and modpath[0] in sys.modules):
3          # setuptools has added into sys.modules a module object with proper
4          # __path__, get back information from there
5          module = sys.modules[modpath.pop(0)]
6 -        path = module.__path__
7 +        # use list() to protect against _NamespacePath instance we get with python 3, which
8 +        # find_module later doesn't like
9 +        path = list(module.__path__)
10          if not modpath:
11              return C_BUILTIN, None
12      imported = []
13      while modpath:
14          modname = modpath[0]