This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author arjennienhuis
Recipients arjennienhuis, benjamin.peterson, eric.smith, loewis, vstinner
Date 2009-07-11.16:28:44
SpamBayes Score 8.631449e-06
Marked as misclassified No
Message-id <11ddbd200907110928r72828d3bxb6a01cdefc56be18@mail.gmail.com>
In-reply-to <4A58B52E.9050302@v.loewis.de>
Content
> 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.
History
Date User Action Args
2009-07-11 16:28:47arjennienhuissetrecipients: + arjennienhuis, loewis, vstinner, eric.smith, benjamin.peterson
2009-07-11 16:28:45arjennienhuislinkissue3982 messages
2009-07-11 16:28:44arjennienhuiscreate