[3.10] bpo-44446: support lineno being None in traceback.FrameSummary (GH-26781) (GH-27072)

As of 088a15c49d, lineno is None instead
of -1 if there is no line number.

Signed-off-by: Filipe Laíns <lains@riseup.net>.
(cherry picked from commit 91a8f8c16c)

Co-authored-by: Filipe Laíns <lains@riseup.net>

Co-authored-by: Filipe Laíns <lains@riseup.net>
This commit is contained in:
Pablo Galindo 2021-07-08 17:47:12 +01:00 committed by GitHub
parent 08697ac5d1
commit 61eb9b5dfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -301,9 +301,10 @@ class FrameSummary:
@property
def line(self):
if self._line is None:
self._line = linecache.getline(self.filename, self.lineno).strip()
return self._line
if self.lineno is None:
return None
self._line = linecache.getline(self.filename, self.lineno)
return self._line.strip()
def walk_stack(f):
"""Walk a stack yielding the frame and line number for each frame.