diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-09-04 23:38:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 23:38:50 (GMT) |
commit | d64d78be20ced6ac9de58e91e69eaba184e36e9b (patch) | |
tree | 8dbc053cbdb99129d22bdfd7e324b79b49d765b2 /Lib/test/test_compile.py | |
parent | 242eac1f0407ba27fd61683eaf34558d5e4ff360 (diff) | |
download | cpython-d64d78be20ced6ac9de58e91e69eaba184e36e9b.zip cpython-d64d78be20ced6ac9de58e91e69eaba184e36e9b.tar.gz cpython-d64d78be20ced6ac9de58e91e69eaba184e36e9b.tar.bz2 |
bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements (GH-21850) (GH-22107)
(cherry picked from commit c51db0ea40ddabaf5f771ea633b37fcf4c90a495)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r-- | Lib/test/test_compile.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 566ca27..55716fd 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -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 |