Stefan Krah added the comment:
Ok, I think the main reason for disallowing zeros in view-shape here
was that casts are undefined if also the shape argument is given:
x = memoryview(b'')
x.cast('d', shape=[1])
Now, this case *is* already caught at a later stage, since there isn't
enough space
Roundup Robot added the comment:
New changeset b08e092df155 by Antoine Pitrou in branch '3.3':
Issue #19014: memoryview.cast() is now allowed on zero-length views.
http://hg.python.org/cpython/rev/b08e092df155
New changeset 1e13a58c1b92 by Antoine Pitrou in branch 'default':
Issue #19014:
Antoine Pitrou added the comment:
Applied Stefan's suggestion. Thanks for the review :)
--
resolution: - fixed
stage: needs patch - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19014
Serhiy Storchaka added the comment:
Thank you Antoine.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19014
___
___
Python-bugs-list mailing
Stefan Krah added the comment:
I agree that this cast should work. Perhaps disallowing zero strides
is enough -- I have to look at this more closely though.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19014
New submission from Serhiy Storchaka:
This is one of most annoying things in Python to me. When you want accept any
bytes-like object in you bytes-processing function you need special case empty
input.
def foo(data):
data = memoryview(data)
if data:
data = data.cast('B')
Antoine Pitrou added the comment:
This actually sounds like a bug to me. A view over the empty bytestring is a
one-dimensional zero-length view, it isn't a special kind of entity.
--
nosy: +ncoghlan
stage: - needs patch
type: enhancement - behavior
versions: +Python 3.3
Serhiy Storchaka added the comment:
Cool. Therefore I can hope on fixing this in maintained releases?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19014
___
Antoine Pitrou added the comment:
Cool. Therefore I can hope on fixing this in maintained releases?
Provided someone makes a patch :-)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19014
Antoine Pitrou added the comment:
Here is a patch. I can't tell whether it's right for sure, since the whole
buffer thing has become so complicated.
--
keywords: +patch
Added file: http://bugs.python.org/file31751/zerocast.patch
___
Python tracker
10 matches
Mail list logo