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/objstr: format: Return bytes result for bytes format string.
This is an improvement over previous behavior when str was returned for
both str and bytes input format. This is also consistent with how % operator and
many other str/bytes methods work.
It should be noted that it's not how current versions of CPython work,
where there's a gap in the functionality and bytes.format() is not
supported.