Message197655
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')
else:
data = b''
You can't use just memoryview(data).cast('B') because it doesn't work for empty data.
>>> memoryview(b'').cast('b')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: memoryview: cannot cast view with zeros in shape or strides
It would be very nice to allow cast() for empty views. |
|
| Date |
User |
Action |
Args |
| 2013-09-13 20:52:29 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, teoliphant, pitrou, skrah |
| 2013-09-13 20:52:29 | serhiy.storchaka | set | messageid: <[email protected]> |
| 2013-09-13 20:52:29 | serhiy.storchaka | link | issue19014 messages |
| 2013-09-13 20:52:29 | serhiy.storchaka | create | |
|