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

2009-07-13 Thread Jorrit Posthuma

Jorrit Posthuma  added the comment:

It's not 'that' clear you should only work with bytes on a socket. 
Especially not when using a wrapper like asynchat. They are supposed to 
make it easier, and passing a string is easier. Maybe it's possible to do 
a default byte conversion when the user is working with strings.

--
nosy: +JPosthuma

___
Python tracker 
<http://bugs.python.org/issue1563>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2009-07-13 Thread Jorrit Posthuma

Jorrit Posthuma  added the comment:

On 13 jul 2009, at 17:33, Jean-Paul Calderone wrote:
>
> Jean-Paul Calderone  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.

It's allso clear to me, but there are people that don't know that.

> 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))?

It's not, I was more thinking of push_str(foo), where it uses a  
default encoding. I think some people don't know what unicode or  
encoding is, or don't want to worry about it.

>
>> 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.

It's not an attack ;), i'm pretty new to Python, and it was just  
something that i noticed (after changing from 2 to 3)

--

___
Python tracker 
<http://bugs.python.org/issue1563>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com