Skip to content

Commit 7ae14e0

Browse files
committed
Fix exception in case of unrecognized source file encoding
1 parent 2e06d6b commit 7ae14e0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gccutils/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ def sorted_dict_repr(d):
2424
def get_src_for_loc(loc):
2525
# Given a gcc.Location, get the source line as a string
2626
import linecache
27-
return linecache.getline(loc.file, loc.line).rstrip()
27+
try:
28+
return linecache.getline(loc.file, loc.line).rstrip()
29+
except SyntaxError: # unrecognized encoding of file
30+
return ''
2831

2932
def get_field_by_name(typeobj, name):
3033
check_isinstance(typeobj,

0 commit comments

Comments
 (0)