[modutils] Ensure module is actually in sys.modules in pkg_resources support

Wrap the long line along the way.

Closes #269083.

authorDenis Laxalde <denis.laxalde@logilab.fr>
changeset9852fab82497
branchdefault
phasepublic
hiddenno
parent revision#0408431e674d [testlib] Remove obsolete backwards compatibility
child revision#60f969ce2b33 [ureports] write unicode not bytes
files modified by this revision
modutils.py
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1414145079 -7200
# Fri Oct 24 12:04:39 2014 +0200
# Node ID 9852fab82497d59bbbc4fc23387ca4aca2c21f33
# Parent 0408431e674df4b6347456f1749262432b304979
[modutils] Ensure module is actually in sys.modules in pkg_resources support

Wrap the long line along the way.

Closes #269083.

diff --git a/modutils.py b/modutils.py
@@ -614,11 +614,14 @@
1                      pic[__path] = None
2          checkeggs = True
3      except AttributeError:
4          checkeggs = False
5      # pkg_resources support (aka setuptools namespace packages)
6 -    if pkg_resources is not None and modpath[0] in pkg_resources._namespace_packages and len(modpath) > 1:
7 +    if (pkg_resources is not None
8 +            and modpath[0] in pkg_resources._namespace_packages
9 +            and modpath[0] in sys.modules
10 +            and len(modpath) > 1):
11          # setuptools has added into sys.modules a module object with proper
12          # __path__, get back information from there
13          module = sys.modules[modpath.pop(0)]
14          path = module.__path__
15      imported = []