summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2019-04-18 00:49:39 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2019-04-18 00:49:39 (GMT)
commit43881bb8c282488f61e2c979ab4435d66390d8a6 (patch)
tree94e5ef6900c8c599b7261b852e75231b5286d785 /src
parentdd1f5a85f85098b6fdfb12e6585f466ad599b48c (diff)
downloadSCons-43881bb8c282488f61e2c979ab4435d66390d8a6.zip
SCons-43881bb8c282488f61e2c979ab4435d66390d8a6.tar.gz
SCons-43881bb8c282488f61e2c979ab4435d66390d8a6.tar.bz2
Issue #3350 - Refactor EnvironmentError to SConsEnvironmentError to avoid overriding python's native EnvironmentError
Diffstat (limited to 'src')
-rwxr-xr-xsrc/CHANGES.txt4
-rw-r--r--src/engine/SCons/EnvironmentTests.py8
-rw-r--r--src/engine/SCons/Errors.py4
-rw-r--r--src/engine/SCons/ErrorsTests.py4
-rw-r--r--src/engine/SCons/Tool/ToolTests.py2
-rw-r--r--src/engine/SCons/Tool/__init__.py12
-rw-r--r--src/engine/SCons/Tool/intelc.py2
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.py2
8 files changed, 21 insertions, 17 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 84a8056..e3b2d1b 100755
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -7,6 +7,10 @@
RELEASE VERSION/DATE TO BE FILLED IN LATER
+ From William Deegan:
+ - Fix Issue #3350 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError.
+ Renamed to SConsEnvironmentError
+
From Mats Wichmann:
- scons-time takes more care closing files and uses safer mkdtemp to avoid
possible races on multi-job runs.
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 2525e0f..760e8d3 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -2433,16 +2433,16 @@ f5: \
exc_caught = None
try:
env.Tool('does_not_exist')
- except SCons.Errors.EnvironmentError:
+ except SCons.Errors.SConsEnvironmentError:
exc_caught = 1
- assert exc_caught, "did not catch expected EnvironmentError"
+ assert exc_caught, "did not catch expected SConsEnvironmentError"
exc_caught = None
try:
env.Tool('$NONE')
- except SCons.Errors.EnvironmentError:
+ except SCons.Errors.SConsEnvironmentError:
exc_caught = 1
- assert exc_caught, "did not catch expected EnvironmentError"
+ assert exc_caught, "did not catch expected SConsEnvironmentError"
# Use a non-existent toolpath directory just to make sure we
# can call Tool() with the keyword argument.
diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py
index 3746d5d..a3a891f 100644
--- a/src/engine/SCons/Errors.py
+++ b/src/engine/SCons/Errors.py
@@ -124,7 +124,7 @@ class UserError(Exception):
class StopError(Exception):
pass
-class EnvironmentError(Exception):
+class SConsEnvironmentError(Exception):
pass
class MSVCError(IOError):
@@ -184,7 +184,7 @@ def convert_to_BuildError(status, exc_info=None):
filename=filename,
exc_info=exc_info)
- elif isinstance(status, (EnvironmentError, OSError, IOError)):
+ elif isinstance(status, (SConsEnvironmentError, OSError, IOError)):
# If an IOError/OSError happens, raise a BuildError.
# Report the name of the file or directory that caused the
# error, which might be different from the target being built
diff --git a/src/engine/SCons/ErrorsTests.py b/src/engine/SCons/ErrorsTests.py
index 5c16160..d777ba1 100644
--- a/src/engine/SCons/ErrorsTests.py
+++ b/src/engine/SCons/ErrorsTests.py
@@ -101,10 +101,10 @@ class ErrorsTestCase(unittest.TestCase):
assert e.node == "node"
def test_convert_EnvironmentError_to_BuildError(self):
- """Test the convert_to_BuildError function on EnvironmentError
+ """Test the convert_to_BuildError function on SConsEnvironmentError
exceptions.
"""
- ee = SCons.Errors.EnvironmentError("test env error")
+ ee = SCons.Errors.SConsEnvironmentError("test env error")
be = SCons.Errors.convert_to_BuildError(ee)
assert be.errstr == "test env error"
assert be.status == 2
diff --git a/src/engine/SCons/Tool/ToolTests.py b/src/engine/SCons/Tool/ToolTests.py
index a4353b1..4bc5106 100644
--- a/src/engine/SCons/Tool/ToolTests.py
+++ b/src/engine/SCons/Tool/ToolTests.py
@@ -72,7 +72,7 @@ class ToolTestCase(unittest.TestCase):
try:
p = SCons.Tool.Tool('_does_not_exist_')
- except SCons.Errors.EnvironmentError:
+ except SCons.Errors.SConsEnvironmentError:
pass
else:
raise
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 8fbd587..c0aa634 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -149,7 +149,7 @@ class Tool(object):
except ImportError as e:
splitname = self.name.split('.')
if str(e) != "No module named %s" % splitname[0]:
- raise SCons.Errors.EnvironmentError(e)
+ raise SCons.Errors.SConsEnvironmentError(e)
try:
import zipimport
except ImportError:
@@ -211,13 +211,13 @@ class Tool(object):
if spec is None:
error_string = "No module named %s" % self.name
- raise SCons.Errors.EnvironmentError(error_string)
+ raise SCons.Errors.SConsEnvironmentError(error_string)
module = importlib.util.module_from_spec(spec)
if module is None:
if debug: print("MODULE IS NONE:%s" % self.name)
error_string = "No module named %s" % self.name
- raise SCons.Errors.EnvironmentError(error_string)
+ raise SCons.Errors.SConsEnvironmentError(error_string)
# Don't reload a tool we already loaded.
sys_modules_value = sys.modules.get(found_name, False)
@@ -258,7 +258,7 @@ class Tool(object):
return module
except ImportError as e:
if str(e) != "No module named %s" % self.name:
- raise SCons.Errors.EnvironmentError(e)
+ raise SCons.Errors.SConsEnvironmentError(e)
try:
import zipimport
importer = zipimport.zipimporter(sys.modules['SCons.Tool'].__path__[0])
@@ -267,10 +267,10 @@ class Tool(object):
return module
except ImportError as e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError(m)
+ raise SCons.Errors.SConsEnvironmentError(m)
except ImportError as e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError(m)
+ raise SCons.Errors.SConsEnvironmentError(m)
def __call__(self, env, *args, **kw):
if self.init_kw is not None:
diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py
index 9fc0bf7..17e7f31 100644
--- a/src/engine/SCons/Tool/intelc.py
+++ b/src/engine/SCons/Tool/intelc.py
@@ -221,7 +221,7 @@ def get_all_compiler_versions():
versions = []
try:
while i < 100:
- subkey = SCons.Util.RegEnumKey(k, i) # raises EnvironmentError
+ subkey = SCons.Util.RegEnumKey(k, i) # raises SConsEnvironmentError
# Check that this refers to an existing dir.
# This is not 100% perfect but should catch common
# installation issues like when the compiler was installed
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py
index 174ab8c..3c2c2f4 100644
--- a/src/engine/SCons/Tool/packaging/__init__.py
+++ b/src/engine/SCons/Tool/packaging/__init__.py
@@ -125,7 +125,7 @@ def Package(env, target=None, source=None, **kw):
# the specific packager is a relative import
return importlib.import_module("." + type, __name__)
except ImportError as e:
- raise EnvironmentError("packager %s not available: %s"%(type,str(e)))
+ raise SConsEnvironmentError("packager %s not available: %s" % (type, str(e)))
packagers = list(map(load_packager, PACKAGETYPE))