Commit 80daa5b3 authored by Stefan Behnel's avatar Stefan Behnel

do not print error context that resulted from encoding errors (i.e. it's unprintable anyway)

parent 761641ea
......@@ -17,10 +17,15 @@ def context(position):
source = position[0]
assert not (isinstance(source, unicode) or isinstance(source, str)), (
"Please replace filename strings with Scanning.FileSourceDescriptor instances %r" % source)
F = list(source.get_lines())
s = ''.join(F[max(0, position[1]-6):position[1]])
s += ' '*(position[2]-1) + '^'
s = '-'*60 + '\n...\n' + s + '\n' + '-'*60 + '\n'
try:
F = list(source.get_lines())
except UnicodeDecodeError:
# file has an encoding problem
s = "[unprintable code]\n"
else:
s =''.join(F[max(0, position[1]-6):position[1]])
s = '...\n' + s + ' '*(position[2]-1) + '^\n'
s = '-'*60 + '\n' + s + '-'*60 + '\n'
return s
class CompileError(PyrexError):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment