[Python-Dev] News from asyncio (original) (raw)
Gustavo Carneiro gjcarneiro at gmail.com
Mon Jan 27 12:10:20 CET 2014
- Previous message: [Python-Dev] News from asyncio
- Next message: [Python-Dev] News from asyncio
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 27 January 2014 10:55, Victor Stinner <victor.stinner at gmail.com> wrote:
2014-01-27 Antoine Pitrou <solipsis at pitrou.net>: > On Mon, 27 Jan 2014 10:45:37 +0100 > Victor Stinner <victor.stinner at gmail.com> wrote: >> >> - Tulip #111: StreamReader.readexactly() now raises an >> IncompleteReadError if the >> end of stream is reached before we received enough bytes, instead of returning >> less bytes than requested. > > Why not simply EOFError?
IncompleteReadError has two additionnal attributes: - partial: "incomplete" received bytes - expected: total number of expected bytes (n parameter of readexactly) I prefer to use a different exception to ensure that these attributes are present. I don't like having to check "hasattr(exc, ...)". Before this change, readexactly(n) returned the partial received bytes if the end of the stream was reached.
I had the same doubt. Note also that IncompleteReadError is a subclass of EOFError, so you can catch EOFError if you like.
Victor
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/gjcarneiro%40gmail.com
-- Gustavo J. A. M. Carneiro Gambit Research LLC "The universe is always one step beyond logic." -- Frank Herbert -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140127/d119ce6a/attachment.html>
- Previous message: [Python-Dev] News from asyncio
- Next message: [Python-Dev] News from asyncio
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]