[pypy-commit] pypy stdlib-2.7.6: cleanups for socket module
bdkearns
noreply at buildbot.pypy.org
Tue Mar 4 21:38:17 CET 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.6
Changeset: r69689:f6af5202851c
Date: 2014-03-04 06:42 -0500
http://bitbucket.org/pypy/pypy/changeset/f6af5202851c/
Log: cleanups for socket module
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
@@ -10,13 +10,6 @@
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter import gateway
-class SignalChecker:
- def __init__(self, space):
- self.space = space
-
- def check(self):
- self.space.getexecutioncontext().checksignals()
-
# XXX Hack to seperate rpython and pypy
def addr_as_object(addr, fd, space):
@@ -197,7 +190,7 @@
def connect_ex_w(self, space, w_addr):
"""connect_ex(address) -> errno
-
+
This is like connect(address), but returns an error code (the errno value)
instead of raising an exception when an error occurs.
"""
@@ -213,7 +206,7 @@
return self.dup(W_RSocket)
except SocketError, e:
raise converted_error(space, e)
-
+
def fileno_w(self, space):
"""fileno() -> integer
@@ -350,7 +343,7 @@
to tell how much data has been sent.
"""
try:
- count = self.sendall(data, flags, SignalChecker(space))
+ self.sendall(data, flags, space.getexecutioncontext().checksignals)
except SocketError, e:
raise converted_error(space, 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
@@ -533,10 +533,10 @@
s.connect(("www.python.org", 80))
except _socket.gaierror, ex:
skip("GAIError - probably no connection: %s" % str(ex.args))
- s.send(buffer(''))
- s.sendall(buffer(''))
- s.send(u'')
- s.sendall(u'')
+ assert s.send(buffer('')) == 0
+ assert s.sendall(buffer('')) is None
+ assert s.send(u'') == 0
+ assert s.sendall(u'') is None
raises(UnicodeEncodeError, s.send, u'\xe9')
s.close()
s = _socket.socket(_socket.AF_INET, _socket.SOCK_DGRAM, 0)
@@ -579,7 +579,7 @@
cls.space = space
HOST = 'localhost'
-
+
def setup_method(self, method):
w_HOST = space.wrap(self.HOST)
self.w_serv = space.appexec([w_socket, w_HOST],
@@ -625,8 +625,8 @@
buf = t.recv(1)
assert buf == '!'
# test that sendall() works
- cli.sendall('?')
- assert count == 1
+ count = cli.sendall('?')
+ assert count is None
buf = t.recv(1)
assert buf == '?'
# test send() timeout
@@ -636,7 +636,7 @@
count += cli.send('foobar' * 70)
except timeout:
pass
- t.recv(count)
+ t.recv(count)
# test sendall() timeout
try:
while 1:
diff --git a/pypy/module/_socket/test/test_ztranslation.py b/pypy/module/_socket/test/test_ztranslation.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_socket/test/test_ztranslation.py
@@ -0,0 +1,5 @@
+from pypy.objspace.fake.checkmodule import checkmodule
+
+
+def test_checkmodule():
+ checkmodule('_socket')
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -898,8 +898,8 @@
except CSocketError, e:
if e.errno != _c.EINTR:
raise
- if signal_checker:
- signal_checker.check()
+ if signal_checker is not None:
+ signal_checker()
finally:
rffi.free_nonmovingbuffer(data, dataptr)
More information about the pypy-commit
mailing list