bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements#21850
bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements#21850markshannon merged 1 commit intopython:masterfrom
Conversation
cc4e135 to
dbeef01
Compare
Python/compile.c
Outdated
There was a problem hiding this comment.
I just made the minimum edit to fix the problem but I would just remove this checkpoint and simply keep incrementing elements and leave the last check fill the dict, which is simpler and less error prone. Any reason we want to flush when we are in USHRT_MAX elements @markshannon ?
To be clear, this is what I propose:
diff --git a/Python/compile.c b/Python/compile.c
index b2beef9327..a348b13676 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3893,19 +3893,7 @@ compiler_dict(struct compiler *c, expr_ty e)
ADDOP_I(c, DICT_UPDATE, 1);
}
else {
- if (elements == USHRT_MAX) {
- if (!compiler_subdict(c, e, i - elements, i + 1)) {
- return 0;
- }
- if (have_dict) {
- ADDOP_I(c, DICT_UPDATE, 1);
- }
- have_dict = 1;
- elements = 0;
- }
- else {
elements++;
- }
}
}
if (elements) {|
My guess is that the I'm merging this as it fixes the issue and adds a test. |
|
Thanks @pablogsal for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
GH-21853 is a backport of this pull request to the 3.9 branch. |
…ments (pythonGH-21850) (cherry picked from commit c51db0e) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
@pablogsal Thanks for the fix. I like the test :) |
Seems that this logic was introduced in this commit: |
|
Thanks @pablogsal for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
…ments (pythonGH-21850) (cherry picked from commit c51db0e) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
GH-22105 is a backport of this pull request to the 3.9 branch. |
|
Thanks @pablogsal for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
Sorry @pablogsal and @markshannon, I had trouble checking out the |
|
Thanks @pablogsal for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
…ments (pythonGH-21850) (cherry picked from commit c51db0e) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
GH-22107 is a backport of this pull request to the 3.9 branch. |
https://bugs.python.org/issue41531