[pypy-commit] pypy sockopt_zero: shorten code path

Alecsandru Patrascu pypy.commits at gmail.com
Mon May 22 09:52:13 EDT 2017


Author: Alecsandru Patrascu <alecsandru.patrascu at rinftech.com>
Branch: sockopt_zero
Changeset: r91367:f848cd62800a
Date: 2017-05-22 16:31 +0300
http://bitbucket.org/pypy/pypy/changeset/f848cd62800a/

Log:	shorten code path

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
@@ -297,17 +297,15 @@
         except SocketError as e:
             raise converted_error(space, e)
 
-    @unwrap_spec(level=int, optname=int)
-    def getsockopt_w(self, space, level, optname, w_buflen=None):
+    @unwrap_spec(level=int, optname=int, buflen=int)
+    def getsockopt_w(self, space, level, optname, buflen=0):
         """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.
         """
-        if w_buflen is not None:
-            buflen = space.int_w(w_buflen)
-        if w_buflen is None or buflen == 0:
+        if buflen == 0:
             try:
                 return space.newint(self.sock.getsockopt_int(level, optname))
             except SocketError as e:


More information about the pypy-commit mailing list