mirror of
https://github.com/python/cpython.git
synced 2024-11-24 00:38:00 +01:00
bpo-26502: Implement FrameSummary.__len__() (GH-8632)
This commit is contained in:
parent
0e0bc4e221
commit
9797b7ae44
@ -868,6 +868,7 @@ class MiscTracebackCases(unittest.TestCase):
|
||||
(__file__, lineno+2, 'test_extract_stack', 'result = extract()'),
|
||||
(__file__, lineno+1, 'extract', 'return traceback.extract_stack()'),
|
||||
])
|
||||
self.assertEqual(len(result[0]), 4)
|
||||
|
||||
|
||||
class TestFrame(unittest.TestCase):
|
||||
@ -900,6 +901,10 @@ class TestFrame(unittest.TestCase):
|
||||
f = traceback.FrameSummary("f", 1, "dummy", line="line")
|
||||
self.assertEqual("line", f.line)
|
||||
|
||||
def test_len(self):
|
||||
f = traceback.FrameSummary("f", 1, "dummy", line="line")
|
||||
self.assertEqual(len(f), 4)
|
||||
|
||||
|
||||
class TestStack(unittest.TestCase):
|
||||
|
||||
|
@ -279,6 +279,9 @@ class FrameSummary:
|
||||
return "<FrameSummary file {filename}, line {lineno} in {name}>".format(
|
||||
filename=self.filename, lineno=self.lineno, name=self.name)
|
||||
|
||||
def __len__(self):
|
||||
return 4
|
||||
|
||||
@property
|
||||
def line(self):
|
||||
if self._line is None:
|
||||
|
@ -0,0 +1,2 @@
|
||||
Implement ``traceback.FrameSummary.__len__()`` method to preserve
|
||||
compatibility with the old tuple API.
|
Loading…
Reference in New Issue
Block a user