Ezio Melotti added the comment: The new patch further improve tests and error message, checking for both numbers and strings:
>>> b = bytearray(b'fooooooo') >>> b[3:4] = 'foo' TypeError: can assign only bytes, buffers, or iterables of ints in range(0, 256) >>> b[3:4] = 5 TypeError: can assign only bytes, buffers, or iterables of ints in range(0, 256) >>> b[3:4] = 5.2 TypeError: can assign only bytes, buffers, or iterables of ints in range(0, 256) >>> b[3:4] = None TypeError: 'NoneType' object is not iterable Before the patch these errors were reported instead: >>> b = bytearray(b'fooooooo') >>> b[3:4] = 'foo' # can't provide encoding here TypeError: string argument without an encoding >>> b[3:4] = 5 # this "worked" >>> b[3:4] = 5.2 TypeError: 'float' object is not iterable >>> b[3:4] = None TypeError: 'NoneType' object is not iterable ---------- Added file: http://bugs.python.org/file27779/issue8401-3.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8401> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com