debug-viewer: Ignore broken utf8 errors

Not much we can do if the input file is not perfectly valid UTF8
but we should just do as good as we can.
This commit is contained in:
Thibault Saunier 2018-04-19 22:13:03 -03:00
parent 29e421ad0a
commit 78698808d2
3 changed files with 4 additions and 4 deletions

View file

@ -344,7 +344,7 @@ class LineCache (Producer):
yield True
offset = tell()
line = readline().decode('utf-8')
line = readline().decode('utf-8', errors='replace')
if not line:
break
match = rexp_match(line)
@ -384,7 +384,7 @@ class LogLine (list):
@classmethod
def parse_full(cls, line_string):
match = cls._line_regex.match(line_string.decode('utf8'))
match = cls._line_regex.match(line_string.decode('utf8', errors='replace'))
if match is None:
# raise ValueError ("not a valid log line (%r)" % (line_string,))
groups = [0, 0, 0, 0, "", "", 0, "", "", 0]

View file

@ -346,7 +346,7 @@ class MessageColumn (TextColumn):
def message_data_func(column, cell, model, tree_iter, user_data):
msg = model.get_value(tree_iter, id_).decode("utf8")
msg = model.get_value(tree_iter, id_).decode("utf8", errors="replace")
if not highlighters:
cell.props.text = msg

View file

@ -690,7 +690,7 @@ class Window (object):
line_text = model.access_offset(line_offset).strip()
line_text = Data.strip_escape(line_text)
self.clipboard.set_text(line_text.decode('utf8'), -1)
self.clipboard.set_text(line_text.decode('utf8', errors='replace'), -1)
@action
def handle_edit_copy_message_action_activate(self, action):