summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compile.py
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2023-01-10 10:56:53 (GMT)
committerGitHub <noreply@github.com>2023-01-10 10:56:53 (GMT)
commitf07daaf4f7a637f9f9324e7c8bf78e8a3faae7e0 (patch)
tree8ced087e09fdf3f372efb7abc3874264d2a235d5 /Lib/test/test_compile.py
parentb2f7b2ef0b5421e01efb8c7bee2ef95d3bab77eb (diff)
downloadcpython-f07daaf4f7a637f9f9324e7c8bf78e8a3faae7e0.zip
cpython-f07daaf4f7a637f9f9324e7c8bf78e8a3faae7e0.tar.gz
cpython-f07daaf4f7a637f9f9324e7c8bf78e8a3faae7e0.tar.bz2
GH-100117: Make `co_lines` more efficient (GH-100447)
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r--Lib/test/test_compile.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 998ce57..f74d2ed 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -161,9 +161,8 @@ if 1:
s256 = "".join(["\n"] * 256 + ["spam"])
co = compile(s256, 'fn', 'exec')
self.assertEqual(co.co_firstlineno, 1)
- lines = list(co.co_lines())
- self.assertEqual(lines[0][2], 0)
- self.assertEqual(lines[1][2], 257)
+ lines = [line for _, _, line in co.co_lines()]
+ self.assertEqual(lines, [0, 257])
def test_literals_with_leading_zeroes(self):
for arg in ["077787", "0xj", "0x.", "0e", "090000000000000",
@@ -955,9 +954,9 @@ if 1:
for func in (no_code1, no_code2):
with self.subTest(func=func):
code = func.__code__
- lines = list(code.co_lines())
- start, end, line = lines[0]
+ [(start, end, line)] = code.co_lines()
self.assertEqual(start, 0)
+ self.assertEqual(end, len(code.co_code))
self.assertEqual(line, code.co_firstlineno)
def get_code_lines(self, code):