diff options
author | Xuanteng Huang <44627253+xuantengh@users.noreply.github.com> | 2024-10-30 09:01:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-30 09:01:09 (GMT) |
commit | 35df4eb959b3923c08aaaeff728c5ed1706f31cf (patch) | |
tree | 0066d2a27b47aaa3fc3dde9debcfd9b553579565 /Lib/test/test_compile.py | |
parent | 2ab377a47c8290f8bf52c8ffb5d7fc4c45452611 (diff) | |
download | cpython-35df4eb959b3923c08aaaeff728c5ed1706f31cf.zip cpython-35df4eb959b3923c08aaaeff728c5ed1706f31cf.tar.gz cpython-35df4eb959b3923c08aaaeff728c5ed1706f31cf.tar.bz2 |
gh-126072: do not add `None` to `co_consts` if there is no docstring (GH-126101)
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r-- | Lib/test/test_compile.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 958170f..85ae71c 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -834,7 +834,7 @@ class TestSpecifics(unittest.TestCase): return "unused" self.assertEqual(f.__code__.co_consts, - (None, "used")) + (True, "used")) @support.cpython_only def test_remove_unused_consts_extended_args(self): @@ -852,9 +852,9 @@ class TestSpecifics(unittest.TestCase): eval(compile(code, "file.py", "exec"), g) exec(code, g) f = g['f'] - expected = tuple([None, ''] + [f't{i}' for i in range(N)]) + expected = tuple([''] + [f't{i}' for i in range(N)]) self.assertEqual(f.__code__.co_consts, expected) - expected = "".join(expected[2:]) + expected = "".join(expected[1:]) self.assertEqual(expected, f()) # Stripping unused constants is not a strict requirement for the @@ -1244,7 +1244,7 @@ class TestSpecifics(unittest.TestCase): y) genexp_lines = [0, 4, 2, 0, 4] - genexp_code = return_genexp.__code__.co_consts[1] + genexp_code = return_genexp.__code__.co_consts[0] code_lines = self.get_code_lines(genexp_code) self.assertEqual(genexp_lines, code_lines) |