Skip to content

Commit 3b4582a

Browse files
ccalmelscyrus-and
authored andcommitted
handle UnicodeDecodeerror in source files
Dealing with bad encoded source file will result in: Traceback (most recent call last): File "<string>", line 538, in render File "<string>", line 1178, in lines File "/usr/lib/python3.9/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 1050: invalid start byte This patch will try to address this issue according to: https://docs.python.org/3/library/codecs.html#error-handlers
1 parent f09356e commit 3b4582a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

.gdbinit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import os
3434
import re
3535
import struct
3636
import traceback
37+
from io import open
3738

3839
# Common attributes ------------------------------------------------------------
3940

@@ -1173,7 +1174,7 @@ class Source(Dashboard.Module):
11731174
if style_changed or file_name != self.file_name or ts and ts > self.ts:
11741175
try:
11751176
# reload the source file if changed
1176-
with open(file_name) as source_file:
1177+
with open(file_name, errors='ignore') as source_file:
11771178
highlighter = Beautifier(file_name, self.tab_size)
11781179
self.highlighted = highlighter.active
11791180
source = highlighter.process(source_file.read())

0 commit comments

Comments
 (0)