
Oct. 2, 2015
4:20 p.m.
On 28.09.2015 03:23, Eric V. Smith wrote:
The only real question is: what encoding to use for the second parameter to bytes()? Since an object must return unicode from __format__(), I need to convert that to bytes in order to join everything together. But how?
Cf. https://www.python.org/dev/peps/pep-0461/#interpolation It says: b"%x" % val is equivalent to: ("%x" % val).encode("ascii") So, ASCII would make a lot of sense to me as well.
Here I suggest 'ascii'. Unfortunately, this would give an error if __format__ returned anything with a char greater than 127. I think we've learned that an API that only raises an exception with certain specific inputs is fragile.
Could you be more specific here? Best, Sven