mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-126072: do not add None
to co_consts
if there is no docstring (GH-126101)
This commit is contained in:
parent
2ab377a47c
commit
35df4eb959
16 changed files with 148 additions and 58 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue