diff options
author | Russel Winder <russel@winder.org.uk> | 2017-08-26 13:46:54 (GMT) |
---|---|---|
committer | Russel Winder <russel@winder.org.uk> | 2017-08-26 13:46:54 (GMT) |
commit | f375f3b8988c559d32566d7709b4190970c650c6 (patch) | |
tree | 20878e20d6085ca1a0910fc401cc0c7275f64bf1 /src/engine | |
parent | 36c1fe9676b8a2f8d4d2174a05cb2d3c47806170 (diff) | |
parent | ecb0e776746503141b7a1b970256e380156739d7 (diff) | |
download | SCons-f375f3b8988c559d32566d7709b4190970c650c6.zip SCons-f375f3b8988c559d32566d7709b4190970c650c6.tar.gz SCons-f375f3b8988c559d32566d7709b4190970c650c6.tar.bz2 |
Merge in mainline.
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/Node/FS.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Tool/MSCommon/vc.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Tool/qt.py | 2 |
5 files changed, 20 insertions, 5 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 8c1161d..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() - 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 399ac06..273f809 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\xdfauge' + test.write('latin1_file', test_string) + f1 = fs.File(test.workpath("latin1_file")) + assert f1.get_text_contents() == test_string.decode('latin-1'), \ + f1.get_text_contents() + def nonexistent(method, s): try: x = method(s, create = 0) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 0409d3b..e186752 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -211,7 +211,7 @@ def get_contents_dir(node): def get_contents_file(node): if not node.rexists(): - return '' + return b'' fname = node.rfile().get_abspath() try: with open(fname, "rb") as fp: diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 7c9eab5..53bd397 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -245,7 +245,9 @@ def find_vc_pdir_vswhere(msvc_version): if os.path.exists(vswhere_path): sp = subprocess.Popen(vswhere_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) vsdir, err = sp.communicate() - vc_pdir = os.path.join(vsdir.rstrip(), 'VC') + vsdir = vsdir.decode("mbcs") + vsdir = vsdir.rstrip() + vc_pdir = os.path.join(vsdir, 'VC') return vc_pdir else: # No vswhere on system, no install info available diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index 5f99054..77269a8 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -144,6 +144,8 @@ class _Automoc(object): # c or fortran source continue #cpp_contents = comment.sub('', cpp.get_text_contents()) + if debug: + print("scons: qt: Getting contents of %s" % cpp) cpp_contents = cpp.get_text_contents() h=None for h_ext in header_extensions: |