[Python-checkins] CVS: python/dist/src/Lib socket.py,1.18,1.19
Tim Peters
tim_one@users.sourceforge.net
Sat, 16 Feb 2002 20:25:26 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv15604/python/Lib
Modified Files:
socket.py
Log Message:
Repair so that importing socket doesn't blow up on platforms that lack
SSL support. test_socket.py passes again on Windows.
Added an XXX about adding _ssl exports to the __all__ list (it doesn't
appear to be doing anything about that now, but since I don't have SSL
on this box I can't really tell).
Index: socket.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/socket.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** socket.py 16 Feb 2002 23:06:18 -0000 1.18
--- socket.py 17 Feb 2002 04:25:24 -0000 1.19
***************
*** 39,57 ****
"""
from _socket import *
try:
from _ssl import *
except ImportError:
! pass
import os, sys
__all__ = ["getfqdn"]
- import _socket
__all__.extend(os._get_exports_list(_socket))
if (sys.platform.lower().startswith("win")
or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")
! or (sys.platform=="riscos")):
_realsocketcall = _socket.socket
--- 39,61 ----
"""
+ import _socket
from _socket import *
+
+ SSL_EXISTS = 1
try:
+ import _ssl
from _ssl import *
except ImportError:
! SSL_EXISTS = 0
import os, sys
__all__ = ["getfqdn"]
__all__.extend(os._get_exports_list(_socket))
+ # XXX shouldn't there be something similar to the above for _ssl exports?
if (sys.platform.lower().startswith("win")
or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")
! or sys.platform=="riscos"):
_realsocketcall = _socket.socket
***************
*** 60,68 ****
return _socketobject(_realsocketcall(family, type, proto))
! try:
_realsslcall = _ssl.ssl
- except AttributeError:
- pass # No ssl
- else:
def ssl(sock, keyfile=None, certfile=None):
if hasattr(sock, "_sock"):
--- 64,69 ----
return _socketobject(_realsocketcall(family, type, proto))
! if SSL_EXISTS:
_realsslcall = _ssl.ssl
def ssl(sock, keyfile=None, certfile=None):
if hasattr(sock, "_sock"):
***************
*** 70,73 ****
--- 71,78 ----
return _realsslcall(sock, keyfile, certfile)
+ del _socket
+ if SSL_EXISTS:
+ del _ssl
+ del SSL_EXISTS
# WSA error codes