diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-02-17 04:25:24 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-02-17 04:25:24 (GMT) |
commit | 18e6778bcdffc68c5b954cb41a6031698e67082e (patch) | |
tree | 7d906f0233a97dea4bd188e2c0f5c14ccd6f6dbe /Lib/socket.py | |
parent | 643a7fc62fd6a9df3325d54ac1ac636d17f3f983 (diff) | |
download | cpython-18e6778bcdffc68c5b954cb41a6031698e67082e.zip cpython-18e6778bcdffc68c5b954cb41a6031698e67082e.tar.gz cpython-18e6778bcdffc68c5b954cb41a6031698e67082e.tar.bz2 |
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).
Diffstat (limited to 'Lib/socket.py')
-rw-r--r-- | Lib/socket.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Lib/socket.py b/Lib/socket.py index 45131ce..153f602 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -38,37 +38,42 @@ Many other constants may be defined; these may be used in calls to the setsockopt() and getsockopt() methods. """ +import _socket from _socket import * + +SSL_EXISTS = 1 try: + import _ssl from _ssl import * except ImportError: - pass + SSL_EXISTS = 0 import os, sys __all__ = ["getfqdn"] -import _socket __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")): + or sys.platform=="riscos"): _realsocketcall = _socket.socket def socket(family, type, proto=0): return _socketobject(_realsocketcall(family, type, proto)) - try: + if SSL_EXISTS: _realsslcall = _ssl.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) +del _socket +if SSL_EXISTS: + del _ssl +del SSL_EXISTS # WSA error codes if sys.platform.lower().startswith("win"): |