Author: Richard Plangger <planri...@gmail.com> Branch: new-jit-log Changeset: r85361:3fa201982b38 Date: 2016-06-23 17:44 +0200 http://bitbucket.org/pypy/pypy/changeset/3fa201982b38/
Log: catchup default diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -42,3 +42,9 @@ Allow rw access to the char* returned from PyString_AS_STRING, also refactor PyStringObject to look like cpython's and allow subclassing PyString_Type and PyUnicode_Type + +.. branch: save_socket_errno + +Bug fix: if ``socket.socket()`` failed, the ``socket.error`` did not show +the errno of the failing system call, but instead some random previous +errno. diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py --- a/rpython/rlib/_rsocket_rffi.py +++ b/rpython/rlib/_rsocket_rffi.py @@ -487,7 +487,9 @@ #hstrerror.argtypes = [c_int] #hstrerror.restype = c_char_p -socket = external('socket', [rffi.INT, rffi.INT, rffi.INT], socketfd_type) +socket = external('socket', [rffi.INT, rffi.INT, rffi.INT], socketfd_type, + save_err=SAVE_ERR) + if WIN32: socketclosename = 'closesocket' diff --git a/rpython/rlib/test/test_rsocket.py b/rpython/rlib/test/test_rsocket.py --- a/rpython/rlib/test/test_rsocket.py +++ b/rpython/rlib/test/test_rsocket.py @@ -589,3 +589,15 @@ return 0 fc = compile(f, [], thread=True) assert fc() == 0 + +def test_socket_saves_errno(tmpdir): + # ensure errno is set to a known value... + unconnected_sock = RSocket() + e = py.test.raises(CSocketError, unconnected_sock.recv, 1024) + # ...which is ENOTCONN + assert e.value.errno == errno.ENOTCONN + + e = py.test.raises(CSocketError, + RSocket, + family=AF_INET, type=SOCK_STREAM, proto=SOL_UDP) + assert e.value.errno in (errno.EPROTOTYPE, errno.EPROTONOSUPPORT) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit