Commit 7e876ae8 authored by Denis Bilenko's avatar Denis Bilenko

hub.py: better error reporting in _import()

parent 04658c38
......@@ -231,12 +231,14 @@ def _import(path):
raise error
if not isinstance(path, basestring):
return path
if '.' not in path:
raise ImportError("Cannot import %r (required format: module.class)" % path)
module, item = path.rsplit('.', 1)
x = __import__(module)
for attr in path.split('.')[1:]:
x = getattr(x, attr, _NONE)
if x is _NONE:
raise ImportError('cannot import name %r from %r' % (attr, x))
raise ImportError('Cannot import name %r from %r' % (attr, x))
return x
......
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