summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-08-13 08:48:41 (GMT)
committerGitHub <noreply@github.com>2020-08-13 08:48:41 (GMT)
commitc51db0ea40ddabaf5f771ea633b37fcf4c90a495 (patch)
tree3a46b03e06f18892609dba444d1232603bcc3cb9 /Lib/test
parent8ecc0c4d390d03de5cd2344aa44b69ed02ffe470 (diff)
downloadcpython-c51db0ea40ddabaf5f771ea633b37fcf4c90a495.zip
cpython-c51db0ea40ddabaf5f771ea633b37fcf4c90a495.tar.gz
cpython-c51db0ea40ddabaf5f771ea633b37fcf4c90a495.tar.bz2
bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements (GH-21850)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_compile.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 3dd8c8d..6055192 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -752,6 +752,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