mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements (GH-21850) (GH-22107)
(cherry picked from commit c51db0ea40
)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
242eac1f04
commit
d64d78be20
3 changed files with 13 additions and 1 deletions
|
@ -750,6 +750,16 @@ if 1:
|
|||
self.assertEqual(None, opcodes[0].argval)
|
||||
self.assertEqual('RETURN_VALUE', opcodes[1].opname)
|
||||
|
||||
def test_big_dict_literal(self):
|
||||
# The compiler has a flushing point in "compiler_dict" that calls compiles
|
||||
# a portion of the dictionary literal when the loop that iterates over the items
|
||||
# reaches 0xFFFF elements but the code was not including the boundary element,
|
||||
# dropping the key at position 0xFFFF. See bpo-41531 for more information
|
||||
|
||||
dict_size = 0xFFFF + 1
|
||||
the_dict = "{" + ",".join(f"{x}:{x}" for x in range(dict_size)) + "}"
|
||||
self.assertEqual(len(eval(the_dict)), dict_size)
|
||||
|
||||
class TestExpressionStackSize(unittest.TestCase):
|
||||
# These tests check that the computed stack size for a code object
|
||||
# stays within reasonable bounds (see issue #21523 for an example
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue