[Zope3-checkins] CVS: Zope3/src/zope/configuration - config.py:1.10
Jim Fulton
jim at zope.com
Sun Sep 21 13:34:10 EDT 2003
Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv16020/src/zope/configuration
Modified Files:
config.py
Log Message:
The old strategy for analyzing import errors was flawed. It could be
broken by installing import hooks.
=== Zope3/src/zope/configuration/config.py 1.9 => 1.10 ===
--- Zope3/src/zope/configuration/config.py:1.9 Sun Aug 17 02:08:49 2003
+++ Zope3/src/zope/configuration/config.py Sun Sep 21 13:34:10 2003
@@ -174,6 +174,22 @@
try:
return __import__(mname+'.'+oname, *_import_chickens)
except ImportError:
+
+ # We need to try to figure out what module the import
+ # error is complaining about. If the import failed
+ # due to a failure to import some other module
+ # imported by the module we are importing, we want to
+ # know it. Unfortunately, the value of the import
+ # error is just a string error message. :( We can't
+ # pull it apart directly to see what module couldn't
+ # be imported. The only thing we can really do is to
+ # try to "screen scrape" the error message:
+
+ if str(sys.exc_info()[1]).find(oname) < 0:
+ # There seems to have been an error further down,
+ # so reraise the exception so as not to hide it.
+ raise
+
raise ConfigurationError("Module %s has no global %s"
% (mname, oname))
More information about the Zope3-Checkins
mailing list