diff options
Diffstat (limited to 'src/engine')
-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): |