mirror of https://github.com/mahmoud/boltons.git
guard against linecache non-safety
This commit is contained in:
parent
6c2296283b
commit
75616c7b94
|
@ -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
|
||||||
linecache.checkcache(self.filename)
|
try:
|
||||||
line = linecache.getline(self.filename,
|
linecache.checkcache(self.filename)
|
||||||
self.lineno,
|
line = linecache.getline(self.filename,
|
||||||
self.module_globals)
|
self.lineno,
|
||||||
line = line.rstrip()
|
self.module_globals)
|
||||||
|
line = line.rstrip()
|
||||||
|
except KeyError:
|
||||||
|
line = ''
|
||||||
self._line = line
|
self._line = line
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue