mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
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:
parent
bbf2fb6c7a
commit
91a8f8c16c
3 changed files with 7 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Take into account that ``lineno`` might be ``None`` in :class:`traceback.FrameSummary`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue