gh-146268: Fix case where assigning an infinite generator to an extend slice hangs instead of raising ValueError by csm10495 · Pull Request #146272 · python/cpython (original) (raw)

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

For me on 3.14.3 and on the latest head of this branch this scenario works the same:

In [1]: a = list(range(10))

In [2]: a
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

In [3]: a[::2] = a
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 a[::2] = a

ValueError: attempt to assign sequence of size 10 to extended slice of size 5

In [4]:

tbd on bytearray and arrray.array