diff options
-rw-r--r-- | src/CHANGES.txt | 1 | ||||
-rw-r--r-- | src/engine/SCons/Errors.py | 10 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 5 | ||||
-rw-r--r-- | src/engine/SCons/UtilTests.py | 4 |
4 files changed, 15 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..88bf53d 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1608,11 +1608,16 @@ 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' + print("to_str %s", repr(s)) 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 |