This contains a number of things:
1) Improve the documentation of the SSL module, with a fuller
explanation of certificate usage, another reference, proper
formatting of this and that.
2) Fix Windows bug in ssl.py, and general bug in sslsocket.close().
Remove some unused code from ssl.py. Allow accept() to be called on
sslsocket sockets.
3) Use try-except-else in import of ssl in socket.py. Deprecate use of
socket.ssl().
4) Remove use of socket.ssl() in every library module, except for
test_socket_ssl.py and test_ssl.py.
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 167bdcb..5f3ec3c 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -91,6 +91,14 @@
if _urlopener:
_urlopener.cleanup()
+# check for SSL
+try:
+ import ssl
+except:
+ _have_ssl = False
+else:
+ _have_ssl = True
+
# exception raised when downloaded size does not match content-length
class ContentTooShortError(IOError):
def __init__(self, message, content):
@@ -361,9 +369,10 @@
fp.close()
raise IOError, ('http error', errcode, errmsg, headers)
- if hasattr(socket, "ssl"):
+ if _have_ssl:
def open_https(self, url, data=None):
"""Use HTTPS protocol."""
+
import httplib
user_passwd = None
proxy_passwd = None