Fix extended slice assignment hanging on infinite iterators#4
Fix extended slice assignment hanging on infinite iterators#4
Conversation
|
@copilot see python#146272 (comment) Fix that. The gist is that in this case the size is undetermined because it's an iterable it shouldn't say the size that we've gotten to this far but rather something along the lines of ValueError: attempt to assign sequence of size 3 to extended slice of larger size. Make minimal changes and update unit tests. Make sure at least one test ensures the correct exception wording for the situation. |
Updated the error messages in
Tests verify the correct exception wording for all three cases. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
3b29ec0 to
26fd46e
Compare
8f1056c to
c1ad027
Compare
When assigning an arbitrary iterable to an extended slice (step != 1), use bounded iteration to collect at most slicelength + 1 items instead of eagerly consuming the entire iterable via PySequence_Fast. This prevents infinite iterators from hanging indefinitely.
Changes Made
"attempt to assign iterable that yielded more items than extended slice of size N""attempt to assign sequence of size N to extended slice of larger size""attempt to assign sequence of size X to extended slice of size Y"blurb addfor Attempting to assign an infinte generator to an extended slice hangs indefinitely instead of raising ValueError python/cpython#146268 attributed to Charles Machalow🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.