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

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

Signed-off-by: Filipe Laíns <lains@riseup.net>
This commit is contained in:
Filipe Laíns 2021-07-08 17:28:01 +01:00 committed by GitHub
parent bbf2fb6c7a
commit 91a8f8c16c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View file

@ -1204,6 +1204,10 @@ def test_lazy_lines(self):
'"""Test cases for traceback module"""',
f.line)
def test_no_line(self):
f = traceback.FrameSummary("f", None, "dummy")
self.assertEqual(f.line, None)
def test_explicit_line(self):
f = traceback.FrameSummary("f", 1, "dummy", line="line")
self.assertEqual("line", f.line)

View file

@ -310,6 +310,8 @@ def _original_line(self):
@property
def line(self):
if self._line is None:
if self.lineno is None:
return None
self._line = linecache.getline(self.filename, self.lineno)
return self._line.strip()

View file

@ -0,0 +1 @@
Take into account that ``lineno`` might be ``None`` in :class:`traceback.FrameSummary`.