Author: Philip Jenvey <pjen...@underboss.org>
Branch: py3k
Changeset: r84548:63484f87ca48
Date: 2016-05-20 17:39 -0700
http://bitbucket.org/pypy/pypy/changeset/63484f87ca48/

Log:    py3 switches to socket.timeout exceptions

diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -137,6 +137,11 @@
                   space.wrap(lib_str) if lib_str else space.w_None)
     return OperationError(w_exception_class, w_exception)
 
+def timeout_error(space, msg):
+    w_exc_class = interp_socket.get_error(space, 'timeout')
+    w_exc = space.call_function(w_exc_class, space.wrap(msg))
+    return OperationError(w_exc_class, w_exc)
+
 class SSLNpnProtocols(object):
 
     def __init__(self, ctx, protos):
@@ -334,7 +339,7 @@
 
         sockstate = checkwait(space, w_socket, True)
         if sockstate == SOCKET_HAS_TIMED_OUT:
-            raise ssl_error(space, "The write operation timed out")
+            raise timeout_error(space, "The write operation timed out")
         elif sockstate == SOCKET_HAS_BEEN_CLOSED:
             raise ssl_error(space, "Underlying socket has been closed.")
         elif sockstate == SOCKET_TOO_LARGE_FOR_SELECT:
@@ -355,7 +360,7 @@
                 sockstate = SOCKET_OPERATION_OK
 
             if sockstate == SOCKET_HAS_TIMED_OUT:
-                raise ssl_error(space, "The write operation timed out")
+                raise timeout_error(space, "The write operation timed out")
             elif sockstate == SOCKET_HAS_BEEN_CLOSED:
                 raise ssl_error(space, "Underlying socket has been closed.")
             elif sockstate == SOCKET_IS_NONBLOCKING:
@@ -392,7 +397,7 @@
         if not count:
             sockstate = checkwait(space, w_socket, False)
             if sockstate == SOCKET_HAS_TIMED_OUT:
-                raise ssl_error(space, "The read operation timed out")
+                raise timeout_error(space, "The read operation timed out")
             elif sockstate == SOCKET_TOO_LARGE_FOR_SELECT:
                 raise ssl_error(space,
                                 "Underlying socket too large for select().")
@@ -432,7 +437,7 @@
                     sockstate = SOCKET_OPERATION_OK
 
                 if sockstate == SOCKET_HAS_TIMED_OUT:
-                    raise ssl_error(space, "The read operation timed out")
+                    raise timeout_error(space, "The read operation timed out")
                 elif sockstate == SOCKET_IS_NONBLOCKING:
                     break
 
@@ -481,7 +486,7 @@
             else:
                 sockstate = SOCKET_OPERATION_OK
             if sockstate == SOCKET_HAS_TIMED_OUT:
-                raise ssl_error(space, "The handshake operation timed out")
+                raise timeout_error(space, "The handshake operation timed out")
             elif sockstate == SOCKET_HAS_BEEN_CLOSED:
                 raise ssl_error(space, "Underlying socket has been closed.")
             elif sockstate == SOCKET_TOO_LARGE_FOR_SELECT:
@@ -549,9 +554,9 @@
 
             if sockstate == SOCKET_HAS_TIMED_OUT:
                 if ssl_err == SSL_ERROR_WANT_READ:
-                    raise ssl_error(space, "The read operation timed out")
+                    raise timeout_error(space, "The read operation timed out")
                 else:
-                    raise ssl_error(space, "The write operation timed out")
+                    raise timeout_error(space, "The write operation timed out")
             elif sockstate == SOCKET_TOO_LARGE_FOR_SELECT:
                 raise ssl_error(space,
                                 "Underlying socket too large for select().")
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to