Permalink
Browse files

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.
  • Loading branch information...
shawnl committed Feb 26, 2018
1 parent e2fdcf2 commit 23d362910b1a6b2dca8a8d49e84620dce7a1345a
Showing with 3 additions and 3 deletions.
  1. +1 −1 include_server/compress_files.py
  2. +1 −1 include_server/include_server.py
  3. +1 −1 include_server/parse_file.py
@@ -98,7 +98,7 @@ def Compress(self, include_closure, client_root_keeper, currdir_idx):
# 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:
@@ -247,7 +247,7 @@ def _delete_temp_files():
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
"",
@@ -278,7 +278,7 @@ def Parse(self, filepath, symbol_table):
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

0 comments on commit 23d3629

Please sign in to comment.