[issue19014] Allow memoryview.cast() for empty views

2013-10-03 Thread Stefan Krah
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

[issue19014] Allow memoryview.cast() for empty views

2013-10-03 Thread Roundup Robot
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:

[issue19014] Allow memoryview.cast() for empty views

2013-10-03 Thread Antoine Pitrou
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

[issue19014] Allow memoryview.cast() for empty views

2013-10-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you Antoine. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19014 ___ ___ Python-bugs-list mailing

[issue19014] Allow memoryview.cast() for empty views

2013-09-15 Thread Stefan Krah
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

[issue19014] Allow memoryview.cast() for empty views

2013-09-13 Thread Serhiy Storchaka
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')

[issue19014] Allow memoryview.cast() for empty views

2013-09-13 Thread Antoine Pitrou
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

[issue19014] Allow memoryview.cast() for empty views

2013-09-13 Thread Serhiy Storchaka
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 ___

[issue19014] Allow memoryview.cast() for empty views

2013-09-13 Thread Antoine Pitrou
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

[issue19014] Allow memoryview.cast() for empty views

2013-09-13 Thread Antoine Pitrou
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