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 · ISSUE
bytes builtin doesn't accept encoding kwarg
Dunno if this is a known problem or has been reported before, but searching for 'bytes' obviously throws up a hell of a lot of matches! ;)
On CPython, I can do both bytes('hello', 'ascii') and bytes('hello', encoding='ascii').
On uPy, the former works, but the latter fails with
TypeError: wrong number of arguments
I also just spotted that on CPython both str(b'hello', 'ascii') and str(b'hello', encoding='ascii') produce the same result, but on uPy the second version returns something quite different. (let me know if I should split that off into a separate issue)