[issue1563] asyncore and asynchat incompatible with Py3k str and bytes

Jean-Paul Calderone report at bugs.python.org
Mon Jul 13 17:33:23 CEST 2009


Jean-Paul Calderone <exarkun at divmod.com> added the comment:

> It's not 'that' clear you should only work with bytes on a socket. 

It's pretty clear to me. :)  That's what sockets can deal with - bytes.
 If you want to transfer something other than bytes via a socket, then
you need to convert it to bytes.  In the case of unicode, there are many
different choices which can be made for how to do this conversion. 
asyncore cannot know what the correct choice is in any particular
situation, so it shouldn't try to make it.

The attached patch forces the application to make this choice,
fortunately.  However, since push_str is only one line, I'm not sure
what the attraction is.  Why is push_str(foo, bar) preferable to
push(foo.encode(bar))?

> Maybe it's possible to do a default byte conversion when the user is
working with strings.

This definitely isn't reasonable and should not be done.  It's also not
what the last proposed patch does, so it doesn't seem to the direction
the other interested parties have been working in.

----------
nosy: +exarkun

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1563>
_______________________________________


More information about the Python-bugs-list mailing list