Nick Coghlan <[EMAIL PROTECTED]> added the comment:

The reason memoryview's current len() implementation is wrong is because
its indexing is per element in the original object, not per byte:

>>> a = array('i', range(10))
>>> m = memoryview(a)
>>> for i in range(len(m)):
...   print(m[i])
...
b'\x00\x00\x00\x00'
b'\x01\x00\x00\x00'
b'\x02\x00\x00\x00'
b'\x03\x00\x00\x00'
b'\x04\x00\x00\x00'
b'\x05\x00\x00\x00'
b'\x06\x00\x00\x00'
b'\x07\x00\x00\x00'
b'\x08\x00\x00\x00'
b'\t\x00\x00\x00'
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
IndexError: index out of bounds

Oops.

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4580>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to