diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-02-12 10:10:32 -0500 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-02-12 10:10:32 -0500 |
commit | 2562bd8951110c419d3a3321905a5d17236bcd72 (patch) | |
tree | 5133bfbfc7360fcb10884241e0a609e6a1ec4aec | |
parent | 99c6dc408b32cc34ac43f4dfcca806441ce0ff6d (diff) | |
parent | 541150de73400d0fea36e241ea76a34596996347 (diff) | |
download | pyopenssl-2562bd8951110c419d3a3321905a5d17236bcd72.tar.gz |
Merge commit '541150d' into release-0.14 (Fix `test_closed` on Windows)
-rw-r--r-- | OpenSSL/SSL.py | 9 | ||||
-rw-r--r-- | OpenSSL/test/test_ssl.py | 7 |
2 files changed, 11 insertions, 5 deletions
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py index ce2cc29..811c4de 100644 --- a/OpenSSL/SSL.py +++ b/OpenSSL/SSL.py @@ -1,4 +1,4 @@ - +from sys import platform from functools import wraps, partial from itertools import count from weakref import WeakValueDictionary @@ -856,8 +856,11 @@ class Connection(object): elif error == _lib.SSL_ERROR_SYSCALL: if _lib.ERR_peek_error() == 0: if result < 0: - raise SysCallError( - _ffi.errno, errorcode[_ffi.errno]) + if platform == "win32": + errno = _ffi.getwinerror()[0] + else: + errno = _ffi.errno + raise SysCallError(errno, errorcode[errno]) else: raise SysCallError(-1, "Unexpected EOF") else: diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py index e366b47..e3518c5 100644 --- a/OpenSSL/test/test_ssl.py +++ b/OpenSSL/test/test_ssl.py @@ -6,7 +6,7 @@ Unit tests for :py:obj:`OpenSSL.SSL`. """ from gc import collect, get_referrers -from errno import ECONNREFUSED, EINPROGRESS, EWOULDBLOCK, EPIPE +from errno import ECONNREFUSED, EINPROGRESS, EWOULDBLOCK, EPIPE, ESHUTDOWN from sys import platform, version_info from socket import SHUT_RDWR, error, socket from os import makedirs @@ -1935,7 +1935,10 @@ class ConnectionSendallTests(TestCase, _LoopbackMixin): server, client = self._loopback() server.sock_shutdown(2) exc = self.assertRaises(SysCallError, server.sendall, b"hello, world") - self.assertEqual(exc.args[0], EPIPE) + if platform == "win32": + self.assertEqual(exc.args[0], ESHUTDOWN) + else: + self.assertEqual(exc.args[0], EPIPE) |