summaryrefslogtreecommitdiffstats
path: root/QMTest/TestCmd.py
diff options
context:
space:
mode:
authorWilliam Blevins <wblevins001@gmail.com>2016-09-20 20:07:30 (GMT)
committerWilliam Blevins <wblevins001@gmail.com>2016-09-20 20:07:30 (GMT)
commit0e2a4161264e7bac8368b8132b368796c880e30e (patch)
tree03ded12777f86fbdae061bdc4199cabe766db2d6 /QMTest/TestCmd.py
parent226c34a47471c5c27bc9a0c262edd62d713acc81 (diff)
downloadSCons-0e2a4161264e7bac8368b8132b368796c880e30e.zip
SCons-0e2a4161264e7bac8368b8132b368796c880e30e.tar.gz
SCons-0e2a4161264e7bac8368b8132b368796c880e30e.tar.bz2
Fixing QMTest str and bytes issues.
Diffstat (limited to 'QMTest/TestCmd.py')
-rw-r--r--QMTest/TestCmd.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index b0a456b..d7b8d94 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -328,12 +328,27 @@ __all__ = [
'match_re_dotall',
'python',
'_python_',
- 'TestCmd'
+ 'TestCmd',
+ 'to_bytes',
+ 'to_str',
]
def is_List(e):
return isinstance(e, (list, UserList))
+def to_bytes (s):
+ if isinstance (s, bytes) or bytes is str:
+ return s
+ else:
+ return bytes (s, 'utf-8')
+
+def to_str (s):
+ if bytes is str:
+ return s
+ elif not is_String(s):
+ return str (s, 'utf-8')
+ return s
+
try:
eval('unicode')
except NameError:
@@ -513,6 +528,8 @@ def simple_diff(a, b, fromfile='', tofile='',
(diff -c) and difflib.unified_diff (diff -u) but which prints
output like the simple, unadorned 'diff" command.
"""
+ a = [to_str(q) for q in a]
+ b = [to_str(q) for q in b]
sm = difflib.SequenceMatcher(None, a, b)
def comma(x1, x2):
return x1+1 == x2 and str(x2) or '%s,%s' % (x1+1, x2)