]> granicus.if.org Git - python/commitdiff
Get rid of a bogus assert when recv_into() is called with a zero-length
authorGuido van Rossum <guido@python.org>
Fri, 3 Aug 2007 22:27:51 +0000 (22:27 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 3 Aug 2007 22:27:51 +0000 (22:27 +0000)
buffer.  We just return 0 in this case now, like for all zero-length
reads.

Modules/socketmodule.c

index f6f577e090f30a70be415d60ffbfd4e8b43a9c08..d9e984486cb434ea4cf073c1f83f0e728b4a01fc 100644 (file)
@@ -2193,6 +2193,10 @@ sock_recv_guts(PySocketSockObject *s, char* cbuf, int len, int flags)
                select_error();
                return -1;
        }
+        if (len == 0) {
+               /* If 0 bytes were requested, do nothing. */
+               return 0;
+       }
 
 #ifndef __VMS
        Py_BEGIN_ALLOW_THREADS
@@ -2322,7 +2326,6 @@ sock_recv_into(PySocketSockObject *s, PyObject *args, PyObject *kwds)
        if (!PyArg_ParseTupleAndKeywords(args, kwds, "w#|ii:recv_into", kwlist,
                                         &buf, &buflen, &recvlen, &flags))
                return NULL;
-       assert(buf != 0 && buflen > 0);
 
        if (recvlen < 0) {
                PyErr_SetString(PyExc_ValueError,