Commit 4591f6ac authored by Armin Rigo's avatar Armin Rigo
Browse files

Issue #3114

Allow general buffers in socket.setsockopt(), like CPython does
parent 1ad4f44a62a4
......@@ -458,7 +458,7 @@ class W_Socket(W_Root):
except OperationError as e:
if e.async(space):
raise
optval = space.bytes_w(w_optval)
optval = space.bufferstr_w(w_optval)
try:
self.sock.setsockopt(level, optname, optval)
except SocketError as e:
......
......@@ -567,6 +567,13 @@ class AppTestSocket:
intsize)
(reuse,) = struct.unpack('i', reusestr)
assert reuse != 0
# try to call setsockopt() with a buffer argument
reusestr = struct.pack('i', 0)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, buffer(reusestr))
reusestr = s.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
intsize)
(reuse,) = struct.unpack('i', reusestr)
assert reuse == 0
def test_getsetsockopt_zero(self):
# related to issue #2561: when specifying the buffer size param:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment