From 97f9431309596152d9cb093172e9752d2b744303 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 22 Jun 2018 17:26:07 -0400 Subject: Create bytearray and not bytes as no bytes type for py2 --- src/engine/SCons/Util.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index b566088..52f42d2 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1607,18 +1607,20 @@ class NullSeq(Null): del __revision__ -def to_bytes (s): + +def to_bytes(s): if s is None: return b'None' if not PY3 and isinstance(s, UnicodeType): # PY2, must encode unicode - return bytes(s, 'utf-8') + return bytearray(s, 'utf-8') if isinstance (s, (bytes, bytearray)) or bytes is str: # Above case not covered here as py2 bytes and strings are the same return s return bytes(s, 'utf-8') -def to_str (s): + +def to_str(s): if s is None: return 'None' if bytes is str or is_String(s): @@ -1626,8 +1628,6 @@ def to_str (s): return str (s, 'utf-8') - -# No cmp in py3, so we'll define it. def cmp(a, b): """ Define cmp because it's no longer available in python3 -- cgit v0.12