Commit 37d38f8d authored by David Wilson's avatar David Wilson

importer: _is_stdlib_name() needed to handle relative paths

Was causing tons of log spam due to 'skipping absent related name'
parent 6ed731c0
...@@ -62,7 +62,8 @@ def _stdlib_paths(): ...@@ -62,7 +62,8 @@ def _stdlib_paths():
] ]
prefixes = (getattr(sys, a) for a in attr_candidates if hasattr(sys, a)) prefixes = (getattr(sys, a) for a in attr_candidates if hasattr(sys, a))
version = 'python%s.%s' % sys.version_info[0:2] version = 'python%s.%s' % sys.version_info[0:2]
return set(os.path.join(p, 'lib', version) for p in prefixes) return set(os.path.abspath(os.path.join(p, 'lib', version))
for p in prefixes)
def get_child_modules(path): def get_child_modules(path):
...@@ -283,7 +284,7 @@ class ModuleFinder(object): ...@@ -283,7 +284,7 @@ class ModuleFinder(object):
return False return False
# six installs crap with no __file__ # six installs crap with no __file__
modpath = getattr(module, '__file__', '') modpath = os.path.abspath(getattr(module, '__file__', ''))
if 'site-packages' in modpath: if 'site-packages' in modpath:
return False return False
...@@ -535,10 +536,10 @@ class ModuleResponder(object): ...@@ -535,10 +536,10 @@ class ModuleResponder(object):
stream.sent_modules.add(fullname) stream.sent_modules.add(fullname)
def _on_get_module(self, msg): def _on_get_module(self, msg):
LOG.debug('%r.get_module(%r)', self, msg)
if msg == mitogen.core._DEAD: if msg == mitogen.core._DEAD:
return return
LOG.debug('%r._on_get_module(%r)', self, msg.data)
stream = self._router.stream_by_id(msg.src_id) stream = self._router.stream_by_id(msg.src_id)
fullname = msg.data fullname = msg.data
if fullname in stream.sent_modules: if fullname in stream.sent_modules:
......
...@@ -532,13 +532,10 @@ class ModuleForwarder(object): ...@@ -532,13 +532,10 @@ class ModuleForwarder(object):
tup = self.importer._cache[fullname] tup = self.importer._cache[fullname]
if tup is not None: if tup is not None:
for related in tup[4]: for related in tup[4]:
LOG.debug('%r._on_get_module(): trying related %r', rtup = self.importer._cache.get(related)
self, related) if not rtup:
try: LOG.debug('%r._on_get_module(): skipping absent %r',
rtup = self.importer._cache[related] self, related)
except KeyError:
LOG.debug('%r._on_get_module(): skipping %r, not in cache',
self, related)
continue continue
self._send_one_module(msg, rtup) self._send_one_module(msg, rtup)
......
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