Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.3k
gh-146268: Fix case where assigning an infinite generator to an extend slice hangs instead of raising ValueError#146272
gh-146268: Fix case where assigning an infinite generator to an extend slice hangs instead of raising ValueError#146272csm10495 wants to merge 5 commits intopython:mainfrom
Conversation
python-cla-botbot commentedMar 22, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
johnslavik commentedMar 22, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This isn't ready yet. The error message from this approach leaks internal implementation details. |
3b29ec0 to26fd46eComparecsm10495 commentedMar 22, 2026
@johnslavik updated based off your feedback. Please check again. |
picnixz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
How does bytearray and array.array handle those cases? likewise what about assigning with itself? does it change the current behavior?a[::2] = a should not be behave differently or if so we should test it
| } | ||
| elseif (step!=1&& | ||
| !PyList_CheckExact(value)&& | ||
| !PyTuple_CheckExact(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Don't we have an FastSequence check for that? (fast sequences are lists or tuples). Also we should not hit this path if we have a known length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't think we have a way to check if it is a fast seq vs trying to create a new one. Agreed on the second part.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
csm10495 commentedMar 22, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
For me on 3.14.3 and on the latest head of this branch this scenario works the same: tbd on bytearray and arrray.array |
8f1056c toc1ad027Comparecsm10495 commentedMar 22, 2026
@picnixz I think i addressed your points. Thanks! |
gh-146268: Fix case where assigning an infinite generator to an extend slice hangs instead of raising ValueError
Also add in some unit tests and a blurb entry.
step != 1is special since we will only perform that assignment if the size of the right matches that of the left. An infinitely sized right hand side can never fill in a (non infinite) left hand side. So we calculate out the left hand side's slice length, then use that to determine if we went over (+1 the left hand's length).