diff options
author | William Deegan <bill@baddogconsulting.com> | 2017-08-24 17:13:35 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2017-08-24 17:13:35 (GMT) |
commit | d8b5708708f3a71ae04a5b8d44a89d5a3d315adb (patch) | |
tree | d334bd22bfc4c4cd30252929558cd93141407475 /src/engine/SCons/Node | |
parent | 38acad8afd2f64dd6e126e359f9d25be177aff2a (diff) | |
download | SCons-d8b5708708f3a71ae04a5b8d44a89d5a3d315adb.zip SCons-d8b5708708f3a71ae04a5b8d44a89d5a3d315adb.tar.gz SCons-d8b5708708f3a71ae04a5b8d44a89d5a3d315adb.tar.bz2 |
Updates to get_text_content() logic and tests
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r-- | src/engine/SCons/Node/FS.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 606ecfd..c31ac6c 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2654,9 +2654,12 @@ class File(Base): if contents[:len(codecs.BOM_UTF16_BE)] == codecs.BOM_UTF16_BE: return contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') try: - return contents.decode('utf-8',errors='backslashreplace') - except (UnicodeDecodeError, AttributeError) as e: - return contents + return contents.decode('utf-8') + except UnicodeDecodeError as e: + try: + return contents.decode('latin-1') + except UnicodeDecodeError as e: + return contents.decode('utf-8', error='backslashreplace') def get_content_hash(self): diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index c211ee1..273f809 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1317,10 +1317,10 @@ class FSTestCase(_tempdirTestCase): # Check for string which doesn't have BOM and isn't valid # ASCII - test_string = b'Gan\xef\xbf\xbdauge' + test_string = b'Gan\xdfauge' test.write('latin1_file', test_string) f1 = fs.File(test.workpath("latin1_file")) - assert f1.get_text_contents() == test_string.decode('utf-8'), \ + assert f1.get_text_contents() == test_string.decode('latin-1'), \ f1.get_text_contents() def nonexistent(method, s): |