Message255907
| Author |
martin.panter |
| Recipients |
BreamoreBoy, eric.araujo, eric.snow, martin.panter, ncoghlan, python-dev, robagar, schlamar |
| Date |
2015年12月05日.00:13:13 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1449274393.6.0.679613335272.issue14285@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I think the problem with doing a blind import of the parent package is it would be hard to differentiate between the ImportError when the package (or an ancestor) is missing, versus a user-generated ImportError. Maybe you could inspect the exception as a workaround (untested):
try:
__import__(pkg_name)
except ImportError as err:
if err.name != pkg_name and not pkg_name.startswith(err.name + "."):
raise
raise error(format(err)) |
|