]>
git.ipfire.org Git - thirdparty/psycopg.git/commit
Raise a TypeError when slice-setting a Multirange with a non-iterable value
The type declaration is:
def __setitem__(index: slice, value: Iterable[Range[T]]) -> None:
...
so passing a non-iterable value should not be allowed. However, the
method implementation makes a special-case for non-iterable values with
a slice.
In accordance with MutableSequence behavior, e.g.:
>>> x = [1, 2, 3]
>>> x[1:3] = 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only assign an iterable
it seems more correct to raise a TypeError.