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.

classification
Title: ascynio readexactly() should raise ValueError if passed length <= 0 in argument
Type: behavior Stage:
Components: asyncio Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, socketpair, vstinner, yselivanov
Priority: normal Keywords:

Created on 2015-11-12 19:11 by socketpair, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (6)
msg254545 - (view) Author: Марк Коренберг (socketpair) * Date: 2015-11-12 19:11
ascynio readexactly() should raise ValueError if passed length <= 0 in argument.

Now, it return empty string, which is just error hiding. Why not to raise ValueError ? 

Returning empty string is error prone. This behaviour was not changed since initial commit of asyncio, so probably was not done intentionally.
msg254549 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-11-12 19:40
I'm okay with raising ValueError for length<0; but for length==0 the
behavior is very much intentional -- reading zero bytes is sometimes a
useful end case that otherwise you would have to work around in the
caller.
msg255510 - (view) Author: Марк Коренберг (socketpair) * Date: 2015-11-27 23:25
result of readexactly(0) is indistinguishable from EOF, so no one should try to use that as I think.

What is the useful case when zero bytes should be read ?
msg255515 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2015-11-28 01:09
read(0) on a regular stream and os.read(fd, 0) also return an empty string without error. This is not something we should keep debating.
msg255590 - (view) Author: Марк Коренберг (socketpair) * Date: 2015-11-29 20:15
Okay, https://github.com/python/asyncio/pull/298 is ready
msg256619 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2015-12-17 22:59
This issue is now resolved (see https://github.com/python/asyncio/pull/298)
History
Date User Action Args
2022-04-11 14:58:23adminsetgithub: 69794
2015-12-17 22:59:07yselivanovsetstatus: open -> closed
resolution: fixed
messages: + msg256619
2015-11-29 20:15:48socketpairsetmessages: + msg255590
2015-11-28 01:09:38gvanrossumsetmessages: + msg255515
2015-11-27 23:25:48socketpairsetmessages: + msg255510
2015-11-12 19:40:24gvanrossumsetmessages: + msg254549
2015-11-12 19:11:15socketpaircreate