mirror of
https://github.com/python/cpython.git
synced 2026-03-30 16:41:06 +00:00
[3.10] bpo-44446: support lineno being None in traceback.FrameSummary (GH-26781) (GH-27072)
As of088a15c49d, lineno is None instead of -1 if there is no line number. Signed-off-by: Filipe Laíns <lains@riseup.net>. (cherry picked from commit91a8f8c16c) Co-authored-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Filipe Laíns <lains@riseup.net>
This commit is contained in:
parent
08697ac5d1
commit
61eb9b5dfd
3 changed files with 9 additions and 3 deletions
|
|
@ -1001,6 +1001,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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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