Chris Jerdonek <chris.jerdo...@gmail.com> added the comment:

I was also hit by this today.

For the sake of clarity, I will restate two of the scenarios that have been 
mentioned in this discussion:

(1) An ImportError raised whilst importing a module (original issue)
(2) A sub-module not existing.

I think the error text should be better in both cases and not just in case (1).

Currently, both (1) and (2) yield an error like the following:

AttributeError: 'module' object has no attribute 'subpackage1'

But also in case (2), the AttributeError reveals less information than the 
exception that was trapped earlier:

ImportError: No module named subpackage1.subpackage2

I think in both cases the error text should state not just what module was 
being imported but also what module was being imported from -- e.g. 
root_package.subpackage1.subpackage2.  In other words, it should also include 
the leading parts of--

'.'.join(parts_copy)  

In my case, I passed a list of modules to unittest, and it wasn't clear which 
one it was failing on by looking at only the trailing segment.  Thanks.

----------
nosy: +cjerdonek

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7559>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to