This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients amaury.forgeotdarc, ncoghlan, pitrou, teoliphant
Date 2008-12-10.11:07:37
SpamBayes Score 2.0099953e-05
Marked as misclassified No
Message-id <1228907258.56.0.867966783989.issue4580@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-12-10 11:07:38ncoghlansetrecipients: + ncoghlan, teoliphant, amaury.forgeotdarc, pitrou
2008-12-10 11:07:38ncoghlansetmessageid: <1228907258.56.0.867966783989.issue4580@psf.upfronthosting.co.za>
2008-12-10 11:07:37ncoghlanlinkissue4580 messages
2008-12-10 11:07:37ncoghlancreate