QUERY · ISSUE
py: bytes() won't call obj.__bytes__()
docs
I defined a class with bytes method. Calling bytes() on its instance should redirect to its bytes method, but it doesn't.
Can this be fixed?
CANDIDATE · PULL REQUEST
py/objarray: Add decode method to bytearray.
Reuse the implementation for bytes since it's exactly the same.
Also found this when working with msgpack where it gets used to get strings instead of bytes, which is too convenient not to use it (e.g. msgpack.unpackb(msgpack.packb('a')) returns b'a' without it). I don' think there is an easy way around here (like dynamically adding a method to a builtin type)?