[issue26644] SSLSocket.recv(-1) triggers SystemError

Martin Panter report at bugs.python.org
Sat Mar 26 18:01:55 EDT 2016


Martin Panter added the comment:

Socket objects aren’t exactly file-like. Plain non-SSL sockets don’t even have read() methods.

I think giving a meaning to recv(-1) would be an (unwanted) new feature, rather than a bug fix. If you want a file-like object linked to a socket, I would suggest using something like the makefile() method instead of adding to the low-level socket object API.

But to answer your question: no, most file methods treat a negative size as a special request to read until EOF, e.g. read(-1), readline(-1) and readlines(-1) of RawIOBase, BufferedIOBase and TextIOBase. On the other hand, BufferedIOBase.read1(-1) is poorly defined and supported (Issue 23214), but may end up meaning something like “read an arbitrary non-zero chunk with a minimum amount of low-level calls and processing”.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26644>
_______________________________________


More information about the Python-bugs-list mailing list