Repository navigation
Conversation
…s `__eq__` advances it Signed-off-by: Sungmin Park <ryan040@korea.ac.kr>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1276
When the key's
__eq__advances the same group iterator while the grouper compares keys (the case from bpo-30347), the nestednext()takes the current value and sets it tonull, and the outernext()then returned that Javanull. Using it crashed the process with aNullPointerException. CPython's_grouper_nextreadscurrvalueafter the comparison too, and returnsNULLwithout an exception when it is gone, which ends the iteration (itertoolsmodule.c#L725-L734).AS-IS
TO-BE
(matching CPython)
Changes
GrouperBuiltins.NextNode, treat anullcurrent value after the key comparison as exhaustion.test_groupby_eq_advances_groupertotests/test_itertools.py: the outernext()returns its default and the nested one gets the next value, as in CPython 3.12, 3.13 and 3.14.Testing
mx python-jvmon darwin-aarch64, thenmx graalpytest test_itertools(9 passed) and--tagged test_itertools(124 passed). The program from #1276 prints0,None,donelike CPython. The new test crashes the 25.6.0 dev build with theNullPointerException.mx checkstyle --primaryandmx eclipseformat --primaryreport nothing.