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 Eric Wieser
Recipients Eric Wieser, skrah
Date 2020-02-11.15:42:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581435772.39.0.91175671687.issue39610@roundup.psfhosted.org>
In-reply-to
Content
Right now, the behavior is:

>>> import numpy as np
>>> arr_0d = np.array(42)
>>> mem_0d = memoryview(arr_0d)
>>> len(mem_0d)
1
>>> mem_0d[0]
TypeError: invalid indexing of 0-dim memory

It seems bizarre to have this object pretend to be a sequence when you ask for its length, yet not behave like one when you actually try to use this length. I'd suggest cpython should behave like numpy here, and fail:

>>> len(arr_0d)
TypeError: len() of unsized object


Perhaps `TypeError: cannot get length of 0-dim memory` would be more appropriate as a message.

---

Wasn't sure how to classify this, feel free to reclassify
History
Date User Action Args
2020-02-11 15:42:52Eric Wiesersetrecipients: + Eric Wieser, skrah
2020-02-11 15:42:52Eric Wiesersetmessageid: <1581435772.39.0.91175671687.issue39610@roundup.psfhosted.org>
2020-02-11 15:42:52Eric Wieserlinkissue39610 messages
2020-02-11 15:42:52Eric Wiesercreate