From d81a3387f0c6ab528986d25bd57a27f549cd0c91 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Tue, 20 Sep 2016 22:34:39 -0400 Subject: Updating to_str and to_bytes between QMTest and SCons.Util. -Added check to skip decode if already string; otherwise, throws TypeError. --- QMTest/TestCmd.py | 9 +++------ src/engine/SCons/Util.py | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index d7b8d94..bff0d6a 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -339,15 +339,12 @@ def is_List(e): def to_bytes (s): if isinstance (s, bytes) or bytes is str: return s - else: - return bytes (s, 'utf-8') + return bytes (s, 'utf-8') def to_str (s): - if bytes is str: + if bytes is str or is_String(s): return s - elif not is_String(s): - return str (s, 'utf-8') - return s + return str (s, 'utf-8') try: eval('unicode') diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 4f4ac2d..6a7e4a1 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1553,14 +1553,12 @@ del __revision__ def to_bytes (s): if isinstance (s, bytes) or bytes is str: return s - else: - return bytes (s, 'utf-8') + return bytes (s, 'utf-8') def to_str (s): - if bytes is str: + if bytes is str or is_String(s): return s - else: - return str (s, 'utf-8') + return str (s, 'utf-8') # Local Variables: # tab-width:4 -- cgit v0.12