[issue4580] slicing of memoryviews when itemsize != 1 is wrong

Nick Coghlan report at bugs.python.org
Wed Dec 10 22:02:05 CET 2008


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Antoine's latest patch looks to me like it will fix the current actual
errors in the 1-D case.

Something that may also be considered part of this bug is the fact that
"m[i] = m[i]" doesn't currently work for itemsize > 1.

There is a XXX comment in the memory view implementation as to whether
we should require "itemsize == itemsize" in addition to "len == len"
when replacing sections of a memoryview. I think the failure of
self-assignment shows that we should only be caring about whether or not
the total memory size being overwritten matches, rather than the
underlying format or size.

Alternatively, we could just special case it and say that assignemnt
from buffers with itemsize=1 (i.e. raw bytes) is always acceptable,
regardless of the itemsize of the buffer underlying the memoryview.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4580>
_______________________________________


More information about the Python-bugs-list mailing list