From a2ba52c55ead4315e1df410469b73ed436efc0d4 Mon Sep 17 00:00:00 2001 From: jkchandalia Date: Mon, 24 Apr 2023 15:22:47 -0700 Subject: [PATCH 1/4] Add test for dis.findlinestarts --- Lib/test/test_dis.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 2d5c73c9adc920..6de074bba4e11d 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1935,6 +1935,15 @@ def test_findlabels(self): self.assertEqual(sorted(labels), sorted(jumps)) + def test_findlinestarts(self): + def func(): + pass + code = func.__code__ + linestarts = list(dis.findlinestarts(code)) + offsets = [linestart[0] for linestart in linestarts] + true_offsets = [0, 2] + self.assertEqual(offsets, true_offsets) + class TestDisTraceback(DisTestBase): def setUp(self) -> None: From 1e22c80eac1787fca74ddacb60da51c54738f5d3 Mon Sep 17 00:00:00 2001 From: Juhi Chandalia Date: Tue, 25 Apr 2023 11:19:05 -0700 Subject: [PATCH 2/4] Improve efficiency and code style Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Lib/test/test_dis.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 6de074bba4e11d..f59bdfc3683817 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1938,11 +1938,10 @@ def test_findlabels(self): def test_findlinestarts(self): def func(): pass + code = func.__code__ - linestarts = list(dis.findlinestarts(code)) - offsets = [linestart[0] for linestart in linestarts] - true_offsets = [0, 2] - self.assertEqual(offsets, true_offsets) + offsets = [linestart[0] for linestart in dis.findlinestarts(code)] + self.assertEqual(offsets, [0, 2]) class TestDisTraceback(DisTestBase): From 552882423ba912b19d0406a6f1077d4221a9f07b Mon Sep 17 00:00:00 2001 From: jkchandalia Date: Tue, 25 Apr 2023 11:46:33 -0700 Subject: [PATCH 3/4] Add name to ACKS --- Misc/ACKS | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/ACKS b/Misc/ACKS index 633e9d90a36f16..19475698a4bc37 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -299,6 +299,7 @@ Dave Chambers Pascal Chambon Nicholas Chammas Ofey Chan +Juhi Chandalia John Chandler Hye-Shik Chang Jeffrey Chang From d34c250c2b9fbfd7cbb1e8912923ef051fc3f8d1 Mon Sep 17 00:00:00 2001 From: jkchandalia Date: Tue, 25 Apr 2023 13:40:25 -0700 Subject: [PATCH 4/4] Clean whitespaces --- Lib/test/test_dis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index f59bdfc3683817..97960726991b76 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1938,7 +1938,7 @@ def test_findlabels(self): def test_findlinestarts(self): def func(): pass - + code = func.__code__ offsets = [linestart[0] for linestart in dis.findlinestarts(code)] self.assertEqual(offsets, [0, 2])