STINNER Victor <victor.stin...@haypocalc.com> added the comment:

> But the comment is actually wrong: It says
> 
> len <= buf_size <= INT_MAX (see above)
> 
> however, len > buf_size may happen, after this code:
> 
>     if (len > buf_size) {
>         PyErr_Format(PyExc_ValueError,
>                      "read() returned too much data: "
>                      "%i bytes requested, %zd returned",
>                      buf_size, len);
>         goto finally;
>     }

Oh. Not only is the comment is wrong, but the code is also wrong. It
should return a negative value on error, whereas it returns the string
length which is always positive (except on a unlikely Py_ssize_t => int
overflow?).

----------

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

Reply via email to