guard against linecache non-safety

This commit is contained in:
Mahmoud Hashemi 2015-02-08 19:00:09 -08:00
parent 6c2296283b
commit 75616c7b94
1 changed files with 8 additions and 5 deletions

View File

@ -112,11 +112,14 @@ class _DeferredLine(object):
def __str__(self): def __str__(self):
if hasattr(self, '_line'): if hasattr(self, '_line'):
return self._line return self._line
try:
linecache.checkcache(self.filename) linecache.checkcache(self.filename)
line = linecache.getline(self.filename, line = linecache.getline(self.filename,
self.lineno, self.lineno,
self.module_globals) self.module_globals)
line = line.rstrip() line = line.rstrip()
except KeyError:
line = ''
self._line = line self._line = line
return line return line