New issue 2561: Passing a buffersize of 0 to socket.getsockopt should be equivalent to not passing it at all https://bitbucket.org/pypy/pypy/issues/2561/passing-a-buffersize-of-0-to
Nathaniel Smith: With CPython: ```python >>> import socket >>> s = socket.socket() >>> s.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 0) 0 ``` With latest PyPy3 nightly build: ```python >>>> import socket >>>> s = socket.socket() >>>> s.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 0) b'' ``` As a special case, CPython treats a zero value for the third argument ("buffersize") as equivalent to it not being passed at all. This isn't documented in the online docs, but it is in the docstring: ```python >>> print(s.getsockopt.__doc__) getsockopt(level, option[, buffersize]) -> value Get a socket option. See the Unix manual for level and option. If a nonzero buffersize argument is given, the return value is a string of that length; otherwise it is an integer. ``` (notice key word "nonzero") This is important because if you want to make a wrapper around getsockopt that pass arguments through, it's convenient to make the wrapper set `buffersize=0` and then unconditionally pass `buffersize` to `socket.getsockopt`. _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue