summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2017-08-23 17:35:15 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2017-08-23 17:35:15 (GMT)
commit06509092b4874d87680fd714927c5a3061528e13 (patch)
tree526cdd49cfebe4be59a14af59a5bd6bd8be606f1 /src/engine
parent73c4b4f12e816eed56f7f67965ff5705899dc09c (diff)
downloadSCons-06509092b4874d87680fd714927c5a3061528e13.zip
SCons-06509092b4874d87680fd714927c5a3061528e13.tar.gz
SCons-06509092b4874d87680fd714927c5a3061528e13.tar.bz2
Fix issue for PY3 where file content has not BOM and isn't ascii by decodeing to utf-8
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Node/FS.py2
-rw-r--r--src/engine/SCons/Node/FSTests.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 8c1161d..638819a 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -2656,7 +2656,7 @@ class File(Base):
try:
return contents.decode()
except (UnicodeDecodeError, AttributeError) as e:
- return contents
+ return contents.decode('utf-8')
def get_content_hash(self):
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 399ac06..c211ee1 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -1315,6 +1315,14 @@ class FSTestCase(_tempdirTestCase):
assert eval('f1.get_text_contents() == u"Foo\x1aBar"'), \
f1.get_text_contents()
+ # Check for string which doesn't have BOM and isn't valid
+ # ASCII
+ test_string = b'Gan\xef\xbf\xbdauge'
+ test.write('latin1_file', test_string)
+ f1 = fs.File(test.workpath("latin1_file"))
+ assert f1.get_text_contents() == test_string.decode('utf-8'), \
+ f1.get_text_contents()
+
def nonexistent(method, s):
try:
x = method(s, create = 0)