summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2017-04-17 22:03:54 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2017-04-17 22:03:54 (GMT)
commit5d9cc286a94b76f748466f4d13a12b7cb4698e7b (patch)
tree10faa1524acd7123d5cd31c936d24c202b252cd7 /src/engine
parent99433738ce86c18b7622d547fa46cee71b06a818 (diff)
parent3e6dce496daca4c98655b4544541828f36dce707 (diff)
downloadSCons-5d9cc286a94b76f748466f4d13a12b7cb4698e7b.zip
SCons-5d9cc286a94b76f748466f4d13a12b7cb4698e7b.tar.gz
SCons-5d9cc286a94b76f748466f4d13a12b7cb4698e7b.tar.bz2
Merged scons/scons into default
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Node/Python.py8
-rw-r--r--src/engine/SCons/Tool/textfile.py6
2 files changed, 12 insertions, 2 deletions
diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py
index 2a3ce98..8c47c97 100644
--- a/src/engine/SCons/Node/Python.py
+++ b/src/engine/SCons/Node/Python.py
@@ -137,7 +137,13 @@ class Value(SCons.Node.Node):
return contents
def get_contents(self):
- return self.get_text_contents().encode()
+ text_contents = self.get_text_contents()
+ try:
+ return text_contents.encode()
+ except UnicodeDecodeError:
+ # Already encoded as python2 str are bytes
+ return text_contents
+
def changed_since_last_build(self, target, prev_ni):
cur_csig = self.get_csig()
diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py
index 0e4d943..42a79cd 100644
--- a/src/engine/SCons/Tool/textfile.py
+++ b/src/engine/SCons/Tool/textfile.py
@@ -71,7 +71,11 @@ def _do_subst(node, subs):
contents = re.sub(k, v, contents)
if 'b' in TEXTFILE_FILE_WRITE_MODE:
- contents = bytearray(contents, 'utf-8')
+ try:
+ contents = bytearray(contents, 'utf-8')
+ except UnicodeDecodeError:
+ # contents is already utf-8 encoded python 2 str i.e. a byte array
+ contents = bytearray(contents)
return contents