# HG changeset patch # User Tero Marttila # Date 1250455543 -10800 # Node ID 8e7037cc05c7104c1dc92f08cb5d28e7508f3ef9 # Parent c44754cc1ffe57fe0e49e1f90d5dcc761d8ffaca fix socket.accept, and add simple PyString_Resize code diff -r c44754cc1ffe -r 8e7037cc05c7 qmsk/net/socket/socket.pyx --- a/qmsk/net/socket/socket.pyx Sun Aug 16 23:32:00 2009 +0300 +++ b/qmsk/net/socket/socket.pyx Sun Aug 16 23:45:43 2009 +0300 @@ -153,7 +153,7 @@ try : # prep the new socket - sock_obj = socket(sock_fd) + sock_obj = socket(fd=sock_fd) except : # XXX: don't leak the socket fd? How does socket.__init__ handle this? @@ -350,9 +350,14 @@ if ret < 0 : raise_errno('recv') + + # truncate to correct length + # XXX: refcounts? + cdef py.PyObject *str_obj = str + + py._PyString_Resize(&str_obj, ret) - # XXX: figure out how to call _PyString_Resize - return str[:ret] + return str_obj def recvfrom (self, size_t len, int flags = 0) : """