Arjen Nienhuis <a.g.nienh...@gmail.com> added the comment:

> def chunk(block):
>   return hex(len(block)).encode('ascii') + b'\r\n' + block + b'\r\n'

hex(10) returns '0xa' instead of 'a'.

> This doesn't need any format call, and describes adequatly how the
> protocol works: send an ASCII-encoded hex length, send CRLF, send
> the block, then send another CRLF. Of course, I would probably write
> that into the socket right away, rather than copying it into a different
> bytes object first.

The point is that need to convert to ascii for each int that you send.
You cannot just wrap the socket with an encoding. This makes porting
difficult.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue3982>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to