[Zope3-checkins] CVS: Zope3/src/zope/configuration - config.py:1.4
Jim Fulton
jim@zope.com
Tue, 29 Jul 2003 16:40:12 -0400
Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv23451/src/zope/configuration
Modified Files:
config.py
Log Message:
Improved the error reporting for import failures to:
- Include the original import error. This may point to a module
imported by the module whose name is given to resolve.
- Include the original traceback, so that it's easier to diagnose
what went wrong.
=== Zope3/src/zope/configuration/config.py 1.3 => 1.4 ===
--- Zope3/src/zope/configuration/config.py:1.3 Tue Jul 29 15:56:42 2003
+++ Zope3/src/zope/configuration/config.py Tue Jul 29 16:39:37 2003
@@ -150,12 +150,20 @@
# Import the module
if not mname:
# Just got a single name. Must me a module
- return __import__(oname, *_import_chickens)
+ mname = oname
+ oname = ''
try:
mod = __import__(mname, *_import_chickens)
- except ImportError:
- raise ConfigurationError("Couldn't import %s" % mname)
+ except ImportError, v:
+ raise ConfigurationError, (
+ "Couldn't import %s, %s" % (mname, v)
+ ), sys.exc_info()[2]
+
+ if not oname:
+ # see not mname case above
+ return mod
+
try:
return getattr(mod, oname)