diff options
author | Gary Oberbrunner <garyo@darkstarsystems.com> | 2018-01-16 01:20:16 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@darkstarsystems.com> | 2018-01-16 02:03:05 (GMT) |
commit | d7897afc9500e7c29d59fba24e6f738093cc515a (patch) | |
tree | f185076bd37596fe6422253d28f27f6e8a184d80 /src/engine/SCons/Util.py | |
parent | 25887d95760e9e4ac65f8bbde3a99a0b3a1d471a (diff) | |
download | SCons-d7897afc9500e7c29d59fba24e6f738093cc515a.zip SCons-d7897afc9500e7c29d59fba24e6f738093cc515a.tar.gz SCons-d7897afc9500e7c29d59fba24e6f738093cc515a.tar.bz2 |
Prevent TypeError with None in error message
I ran into a problem where SCons was generating an error that
contained a None (don't ask me how), and this got passed through
to_str() which caused a TypeError because None isn't a bytes-like
object.
I fixed it two ways: enable to_str and to_bytes to handle None without
complaint, and change Errors.py to use to_String() instead of to_str(),
since it seems more robust.
Diffstat (limited to 'src/engine/SCons/Util.py')
-rw-r--r-- | src/engine/SCons/Util.py | 5 |
1 files changed, 5 insertions, 0 deletions
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') |