summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2009-04-30 05:21:12 (GMT)
committerSteven Knight <knight@baldmt.com>2009-04-30 05:21:12 (GMT)
commitfc0796034248d84fa541c1a2d7b2e3eda1a26872 (patch)
treec2e8844dd136347a78cecefe66f41d9784a4fcbf /src/engine/SCons/Script
parentf336f13ec93285dc4f5caf00d79a7f2086e5786a (diff)
downloadSCons-fc0796034248d84fa541c1a2d7b2e3eda1a26872.zip
SCons-fc0796034248d84fa541c1a2d7b2e3eda1a26872.tar.gz
SCons-fc0796034248d84fa541c1a2d7b2e3eda1a26872.tar.bz2
Fix try:-except:-finally: block, only valid starting with Python 2.5.
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r--src/engine/SCons/Script/Main.py46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 926cf5c..a8ec8f6 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -698,30 +698,34 @@ def _load_site_scons_dir(topdir, site_dir_name=None):
site_tools_dir = os.path.join(site_dir, site_tools_dirname)
if os.path.exists(site_init_file):
import imp
+ # TODO(2.4): turn this into try:-except:-finally:
try:
- fp, pathname, description = imp.find_module(site_init_modname,
- [site_dir])
- # Load the file into SCons.Script namespace. This is
- # opaque and clever; m is the module object for the
- # SCons.Script module, and the exec ... in call executes a
- # file (or string containing code) in the context of the
- # module's dictionary, so anything that code defines ends
- # up adding to that module. This is really short, but all
- # the error checking makes it longer.
try:
- m=sys.modules['SCons.Script']
- except Exception, e:
- raise SCons.Errors.InternalError, \
- "can't import site_init.py: missing SCons.Script module, %s"%str(e)
- try:
- # This is the magic.
- exec fp in m.__dict__
- except Exception, e:
- sys.stderr.write("*** Error loading site_init file %s:\n"%site_init_file)
+ fp, pathname, description = imp.find_module(site_init_modname,
+ [site_dir])
+ # Load the file into SCons.Script namespace. This is
+ # opaque and clever; m is the module object for the
+ # SCons.Script module, and the exec ... in call executes a
+ # file (or string containing code) in the context of the
+ # module's dictionary, so anything that code defines ends
+ # up adding to that module. This is really short, but all
+ # the error checking makes it longer.
+ try:
+ m = sys.modules['SCons.Script']
+ except Exception, e:
+ fmt = 'cannot import site_init.py: missing SCons.Script module %s'
+ raise SCons.Errors.InternalError, fmt % repr(e)
+ try:
+ # This is the magic.
+ exec fp in m.__dict__
+ except Exception, e:
+ fmt = '*** Error loading site_init file %s:\n'
+ sys.stderr.write(fmt % repr(site_init_file))
+ raise
+ except ImportError, e:
+ fmt = '*** cannot import site init file %s:\n'
+ sys.stderr.write(fmt % repr(site_init_file))
raise
- except ImportError, e:
- sys.stderr.write("Can't import site init file '%s':\n"%site_init_file)
- raise
finally:
if fp:
fp.close()