[pypy-commit] pypy default: Issue #3114
arigo
pypy.commits at gmail.com
Fri Nov 15 15:01:05 EST 2019
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r98060:4234613045bb
Date: 2019-11-15 20:59 +0100
http://bitbucket.org/pypy/pypy/changeset/4234613045bb/
Log: Issue #3114
Allow general buffers in socket.setsockopt(), like CPython does
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
@@ -458,7 +458,7 @@
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:
diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -567,6 +567,13 @@
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:
More information about the pypy-commit
mailing list