[Python-checkins] cpython: Update example of non-blocking SSL code for the new finer-grained exceptions

antoine.pitrou python-checkins at python.org
Fri Oct 28 00:03:12 CEST 2011


http://hg.python.org/cpython/rev/dfeea8cb1910
changeset:   73151:dfeea8cb1910
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Thu Oct 27 23:59:03 2011 +0200
summary:
  Update example of non-blocking SSL code for the new finer-grained exceptions

files:
  Doc/library/ssl.rst |  11 ++++-------
  1 files changed, 4 insertions(+), 7 deletions(-)


diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -1044,13 +1044,10 @@
         try:
             sock.do_handshake()
             break
-        except ssl.SSLError as err:
-            if err.args[0] == ssl.SSL_ERROR_WANT_READ:
-                select.select([sock], [], [])
-            elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
-                select.select([], [sock], [])
-            else:
-                raise
+        except ssl.SSLWantReadError:
+            select.select([sock], [], [])
+        except ssl.SSLWantWriteError:
+            select.select([], [sock], [])
 
 
 .. _ssl-security:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list