Message101867
| Author |
chris.jerdonek |
| Recipients |
chris.jerdonek, michael.foord, r.david.murray, rbcollins, slmnhq |
| Date |
2010年03月28日.16:02:47 |
| SpamBayes Score |
1.5890471e-08 |
| Marked as misclassified |
No |
| Message-id |
<1269792170.42.0.591622207427.issue7559@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|