summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2018-01-16 14:39:18 (GMT)
committerGitHub <noreply@github.com>2018-01-16 14:39:18 (GMT)
commitdd1aa985c729ea549048e2009294980ef079f1de (patch)
tree81c449508f0dee8c2d7ca6be52904a5846536028
parent87bfc9191104693bc2fb1a74971eb2014f96e256 (diff)
parent58e4a93c0dc807d01d77c6da523bd9e15e6be418 (diff)
downloadSCons-dd1aa985c729ea549048e2009294980ef079f1de.zip
SCons-dd1aa985c729ea549048e2009294980ef079f1de.tar.gz
SCons-dd1aa985c729ea549048e2009294980ef079f1de.tar.bz2
Merge pull request #3046 from garyo/master
Prevent TypeError with None in error message
-rw-r--r--src/CHANGES.txt1
-rw-r--r--src/engine/SCons/Errors.py10
-rw-r--r--src/engine/SCons/Util.py4
-rw-r--r--src/engine/SCons/UtilTests.py4
4 files changed, 14 insertions, 5 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 0028524..42b44d7 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -9,6 +9,7 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
From Gary Oberbrunner:
- Fix bug when Installing multiple subdirs outside the source tree
+ - fix to_str to handle None without raising exception
From Mats Wichmann:
- Updated manpage scons.xml to fix a nested list problem
diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py
index 2ba007c..dae20b2 100644
--- a/src/engine/SCons/Errors.py
+++ b/src/engine/SCons/Errors.py
@@ -95,7 +95,7 @@ class BuildError(Exception):
# py3: errstr should be string and not bytes.
- self.errstr = SCons.Util.to_str(errstr)
+ self.errstr = SCons.Util.to_String(errstr)
self.status = status
self.exitstatus = exitstatus
self.filename = filename
@@ -176,8 +176,8 @@ def convert_to_BuildError(status, exc_info=None):
filename = status.filename
except AttributeError:
filename = None
-
- buildError = BuildError(
+
+ buildError = BuildError(
errstr=status.args[0],
status=status.errno,
exitstatus=2,
@@ -195,7 +195,7 @@ def convert_to_BuildError(status, exc_info=None):
except AttributeError:
filename = None
- buildError = BuildError(
+ buildError = BuildError(
errstr=status.strerror,
status=status.errno,
exitstatus=2,
@@ -217,7 +217,7 @@ def convert_to_BuildError(status, exc_info=None):
errstr="Error %s" % status,
status=status,
exitstatus=2)
-
+
#import sys
#sys.stderr.write("convert_to_BuildError: status %s => (errstr %s, status %s)\n"%(status,buildError.errstr, buildError.status))
return buildError
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 558441d..ec29796 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1608,11 +1608,15 @@ class NullSeq(Null):
del __revision__
def to_bytes (s):
+ if s is None:
+ return b'None'
if isinstance (s, (bytes, bytearray)) or bytes is str:
return s
return bytes (s, 'utf-8')
def to_str (s):
+ if s is None:
+ return 'None'
if bytes is str or is_String(s):
return s
return str (s, 'utf-8')
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index 0d1b7bb..6b12f8a 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -312,6 +312,10 @@ class UtilTestCase(unittest.TestCase):
assert to_String(1) == "1", to_String(1)
assert to_String([ 1, 2, 3]) == str([1, 2, 3]), to_String([1,2,3])
assert to_String("foo") == "foo", to_String("foo")
+ assert to_String(None) == 'None'
+ # test low level string converters too
+ assert to_str(None) == 'None'
+ assert to_bytes(None) == b'None'
s1=UserString('blah')
assert to_String(s1) == s1, s1