summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-03-22 22:12:17 (GMT)
committerGuido van Rossum <guido@python.org>2001-03-22 22:12:17 (GMT)
commit3f69f216446f545edb353fe6db135e2fca51a348 (patch)
tree4b09e17678208ac7a3de1d505dd765736b2d730e /Lib/socket.py
parentbfb9184ba80fc14a6d773e72fc591250f668ed3a (diff)
downloadcpython-3f69f216446f545edb353fe6db135e2fca51a348.zip
cpython-3f69f216446f545edb353fe6db135e2fca51a348.tar.gz
cpython-3f69f216446f545edb353fe6db135e2fca51a348.tar.bz2
Add a wrapper function for ssl() on Windows. Inspired by SF patch
# 409287, ssl fix when using _socketobject, by Robin Dunn. I took the opportunity to improve the way it deals with reload(socket) for the socket function as well.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index a49e7cb..7cd7889 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -45,21 +45,26 @@ import os, sys
__all__ = ["getfqdn"]
import _socket
__all__.extend(os._get_exports_list(_socket))
-del _socket
if (sys.platform.lower().startswith("win")
or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")
or (sys.platform=="RISCOS")):
- # be sure this happens only once, even in the face of reload():
- try:
- _realsocketcall
- except NameError:
- _realsocketcall = socket
+ _realsocketcall = _socket.socket
def socket(family, type, proto=0):
return _socketobject(_realsocketcall(family, type, proto))
+ try:
+ _realsslcall = _socket.ssl
+ except AttributeError:
+ pass # No ssl
+ else:
+ def ssl(sock, keyfile=None, certfile=None):
+ if hasattr(sock, "_sock"):
+ sock = sock._sock
+ return _realsslcall(sock, keyfile, certfile)
+
# WSA error codes
if sys.platform.lower().startswith("win"):