summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJane Doe <jdoe@example.com>2017-05-28 06:38:53 (GMT)
committerJane Doe <jdoe@example.com>2017-05-28 06:38:53 (GMT)
commit948f492fc307bc974885388ecfdde126143ca6c0 (patch)
treead2e1f1bb17578b6758220062a0f567eed828ba2
parent8c2bfc326ce26ff3f3f10dee5adee2d9a6a0c514 (diff)
downloadSCons-948f492fc307bc974885388ecfdde126143ca6c0.zip
SCons-948f492fc307bc974885388ecfdde126143ca6c0.tar.gz
SCons-948f492fc307bc974885388ecfdde126143ca6c0.tar.bz2
py2/3 fix to_bytes to not stringify bytearrays. Fix MD5signiture to not stringify if not needed contents
-rw-r--r--src/engine/SCons/Util.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 3ce7fe4..31213e1 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -32,6 +32,7 @@ import copy
import re
import types
import codecs
+import pprint
PY3 = sys.version[0] == 3
@@ -497,7 +498,13 @@ def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst,
try:
f = obj.for_signature
except AttributeError:
- return to_String_for_subst(obj)
+ if isinstance(obj, dict):
+ # pprint will output dictionary in key sorted order
+ # with py3.5 the order was randomized. In general depending on dictionary order
+ # which was undefined until py3.6 (where it's by insertion order) was not wise.
+ return pprint.pformat(obj, width=1000000)
+ else:
+ return to_String_for_subst(obj)
else:
return f()
@@ -1515,7 +1522,12 @@ else:
def MD5signature(s):
m = hashlib.md5()
- m.update(to_bytes(str(s)))
+
+ try:
+ m.update(to_bytes(s))
+ except TypeError as e:
+ m.update(to_bytes(str(s)))
+
return m.hexdigest()
def MD5filesignature(fname, chunksize=65536):
@@ -1525,7 +1537,7 @@ else:
blck = f.read(chunksize)
if not blck:
break
- m.update(to_bytes (str(blck)))
+ m.update(to_bytes(blck))
f.close()
return m.hexdigest()
@@ -1602,7 +1614,7 @@ class NullSeq(Null):
del __revision__
def to_bytes (s):
- if isinstance (s, bytes) or bytes is str:
+ if isinstance (s, (bytes, bytearray)) or bytes is str:
return s
return bytes (s, 'utf-8')