[3.10] bpo-44446: support lineno being None in traceback.FrameSummary (GH-26781) (GH-27072)
As of 088a15c49d99ecb4c3bef93f8f40dd513c6cae3b, 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 91a8f8c16ca9a7e2466a8241d9b41769ef97d094)
Co-authored-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Filipe Laíns <lains@riseup.net>
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 7a7cca1..463cb22 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -301,9 +301,10 @@ def __len__(self):
@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.