[pypy-commit] pypy py3k: Make sockets really subclassable

amauryfa noreply at buildbot.pypy.org
Wed Oct 19 01:43:24 CEST 2011

Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r48220:4c11bf0deece
Date: 2011-10-18 22:45 +0200

Log:	Make sockets really subclassable

diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -415,13 +415,9 @@
 @unwrap_spec(family=int, type=int, proto=int)
 def newsocket(space, w_subtype, family=AF_INET,
               type=SOCK_STREAM, proto=0):
-    # XXX If we want to support subclassing the socket type we will need
-    # something along these lines. But allocate_instance is only defined
-    # on the standard object space, so this is not really correct.
-    #sock = space.allocate_instance(W_RSocket, w_subtype)
-    #Socket.__init__(sock, space, fd, family, type, proto)
+    sock = space.allocate_instance(W_RSocket, w_subtype)
-        sock = W_RSocket(family, type, proto)
+        W_RSocket.__init__(sock, family, type, proto)
     except SocketError, e:
         raise converted_error(space, e)
     return space.wrap(sock)

More information about the pypy-commit mailing list