]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-26502: Implement FrameSummary.__len__() (GH-8632)
authorBerker Peksag <berker.peksag@gmail.com>
Mon, 10 Sep 2018 17:02:33 +0000 (20:02 +0300)
committerPetr Viktorin <encukou@gmail.com>
Mon, 10 Sep 2018 17:02:33 +0000 (10:02 -0700)
Lib/test/test_traceback.py
Lib/traceback.py
Misc/NEWS.d/next/Library/2018-08-02-20-39-32.bpo-26502.eGXr_k.rst [new file with mode: 0644]

index 8a3aa8a8648f86c5aa1d3a42b23db1b3a413ed87..3af85b81721eccd57dca671b6adba660b01819c1 100644 (file)
@@ -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):
 
index 4e7605d15fa4dea141709bb55dc8b96255715d99..ab35da94b51eabe297a12185762e4076c59fd46b 100644 (file)
@@ -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:
diff --git a/Misc/NEWS.d/next/Library/2018-08-02-20-39-32.bpo-26502.eGXr_k.rst b/Misc/NEWS.d/next/Library/2018-08-02-20-39-32.bpo-26502.eGXr_k.rst
new file mode 100644 (file)
index 0000000..3a3fc17
--- /dev/null
@@ -0,0 +1,2 @@
+Implement ``traceback.FrameSummary.__len__()`` method to preserve
+compatibility with the old tuple API.