diff options
author | Shawn Landden <slandden@gmail.com> | 2018-02-25 20:47:32 -0800 |
---|---|---|
committer | Shawn Landden <slandden@gmail.com> | 2018-02-25 20:52:40 -0800 |
commit | 23d362910b1a6b2dca8a8d49e84620dce7a1345a (patch) | |
tree | 23cebf836c555f2a26082cfe9e48c6a38cc04c5e | |
parent | e2fdcf24a03f2820fffaaa60021fb63fae6d46aa (diff) | |
download | distcc-git-23d362910b1a6b2dca8a8d49e84620dce7a1345a.tar.gz |
pump: attempt to eliminate UnicodeDecodeError for good
All places where we read files, do so in 'latin-1' so that
all encodings are valid. As we only need to understand ASCII
stuff and ignore the rest this should work fine.
Does require python3.
-rwxr-xr-x | include_server/compress_files.py | 2 | ||||
-rwxr-xr-x | include_server/include_server.py | 2 | ||||
-rwxr-xr-x | include_server/parse_file.py | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/include_server/compress_files.py b/include_server/compress_files.py index 880551e..78c977d 100755 --- a/include_server/compress_files.py +++ b/include_server/compress_files.py @@ -98,7 +98,7 @@ class CompressFiles(object): # change its name. prefix = "" try: - real_file_fd = open(realpath, "r") + real_file_fd = open(realpath, "r", encoding='latin-1') except (IOError, OSError) as why: sys.exit("Could not open '%s' for reading: %s" % (realpath, why)) try: diff --git a/include_server/include_server.py b/include_server/include_server.py index 3b50247..c03e349 100755 --- a/include_server/include_server.py +++ b/include_server/include_server.py @@ -247,7 +247,7 @@ def ExactDependencies(cmd, realpath_map, systemdir_prefix_cache, translation_unit) # Using the primitive fd_d file descriptor for reading is cumbersome, so open # normally as well. - fd_d_ = open(name_d, "rb") + fd_d_ = open(name_d, "rb", encoding='latin-1') # Massage the contents of fd_d_ dotd = re.sub("^.*:", # remove Makefile target "", diff --git a/include_server/parse_file.py b/include_server/parse_file.py index 5df853f..d1dcc74 100755 --- a/include_server/parse_file.py +++ b/include_server/parse_file.py @@ -278,7 +278,7 @@ class ParseFile(object): includepath_map_index = self.includepath_map.Index try: - fd = open(filepath, "r") + fd = open(filepath, "r", encoding='latin-1') except IOError as msg: # This normally does not happen because the file should be known to # exists. Still there might be, say, a permissions issue that prevents it |