Skip to content

Commit

Permalink
pump: attempt to eliminate UnicodeDecodeError for good
Browse files Browse the repository at this point in the history
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 23d3629
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include_server/compress_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion include_server/include_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"",
Expand Down
2 changes: 1 addition & 1 deletion include_server/parse_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23d3629

Please sign in to comment.