Merged revisions 57620-57771 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r57771 | thomas.wouters | 2007-08-30 23:54:39 +0200 (Thu, 30 Aug 2007) | 5 lines


  Don't lie in __all__ attributes when SSL is not available: only add the SSL
  classes when they are actually created.

........
  r57620 | walter.doerwald | 2007-08-28 18:38:26 +0200 (Tue, 28 Aug 2007) | 5 lines

  Fix title endtag in HTMLCalender.formatyearpage(). Fix documentation for
  HTMLCalender.formatyearpage() (there's no themonth parameter).

  This fixes issue1046.
........
  r57622 | georg.brandl | 2007-08-28 20:54:44 +0200 (Tue, 28 Aug 2007) | 2 lines

  Add a crasher for the thread-unsafety of file objects.
........
  r57626 | skip.montanaro | 2007-08-29 01:22:52 +0200 (Wed, 29 Aug 2007) | 1 line

  fixes 813986
........
  r57628 | walter.doerwald | 2007-08-29 01:35:33 +0200 (Wed, 29 Aug 2007) | 2 lines

  Fix test output.
........
  r57631 | skip.montanaro | 2007-08-29 03:24:11 +0200 (Wed, 29 Aug 2007) | 2 lines

  Install pygettext (once the scriptsinstall target is working again).
........
  r57633 | skip.montanaro | 2007-08-29 03:33:45 +0200 (Wed, 29 Aug 2007) | 2 lines

  Recent items.
........
  r57650 | neal.norwitz | 2007-08-29 08:15:33 +0200 (Wed, 29 Aug 2007) | 1 line

  Add Bill as a developer
........
  r57651 | facundo.batista | 2007-08-29 12:28:28 +0200 (Wed, 29 Aug 2007) | 5 lines


  Ignore test failures caused by 'resource temporarily unavailable'
  exceptions raised during FailingServerTestCase tests.
  [GSoC - Alan McIntyre]
........
  r57680 | bill.janssen | 2007-08-30 00:35:05 +0200 (Thu, 30 Aug 2007) | 17 lines

  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.
........
  r57714 | georg.brandl | 2007-08-30 12:09:42 +0200 (Thu, 30 Aug 2007) | 2 lines

  Stronger urge to convert filenames to str before using them as argument to ZipFile.write().
........
  r57716 | georg.brandl | 2007-08-30 12:38:56 +0200 (Thu, 30 Aug 2007) | 2 lines

  Patch #1680959: add test suite for pipes module.
........
  r57717 | georg.brandl | 2007-08-30 14:32:23 +0200 (Thu, 30 Aug 2007) | 3 lines

  * Skip test_pipes on non-POSIX.
  * Don't raise TestSkipped within a test function.
........
  r57723 | mark.summerfield | 2007-08-30 17:03:03 +0200 (Thu, 30 Aug 2007) | 3 lines

  Added more cross-references.
........
  r57726 | walter.doerwald | 2007-08-30 17:30:09 +0200 (Thu, 30 Aug 2007) | 2 lines

  Rewrap line.
........
  r57727 | walter.doerwald | 2007-08-30 17:34:55 +0200 (Thu, 30 Aug 2007) | 2 lines

  Set startinpos before calling the error handler.
........
  r57730 | bill.janssen | 2007-08-30 19:07:28 +0200 (Thu, 30 Aug 2007) | 3 lines

  Added docstrings to methods and functions.
........
  r57743 | bill.janssen | 2007-08-30 20:08:06 +0200 (Thu, 30 Aug 2007) | 1 line

  added note on new ssl module and deprecation of socket.ssl
........
  r57747 | martin.v.loewis | 2007-08-30 20:14:01 +0200 (Thu, 30 Aug 2007) | 1 line

  Fix popen usage.
........
  r57748 | martin.v.loewis | 2007-08-30 20:15:22 +0200 (Thu, 30 Aug 2007) | 1 line

  Fix typo.
........
  r57750 | martin.v.loewis | 2007-08-30 20:25:47 +0200 (Thu, 30 Aug 2007) | 1 line

  Bug #1746880: Correctly install DLLs into system32 folder on Win64.
........
  r57760 | martin.v.loewis | 2007-08-30 21:04:09 +0200 (Thu, 30 Aug 2007) | 1 line

  Bug #1709599: Run test_1565150 only if the file system is NTFS.
........
  r57762 | martin.v.loewis | 2007-08-30 22:10:57 +0200 (Thu, 30 Aug 2007) | 2 lines

  Bump autoconf minimum version to 2.61.
........
  r57764 | lars.gustaebel | 2007-08-30 22:24:31 +0200 (Thu, 30 Aug 2007) | 2 lines

  Warn about possible risks when extracting untrusted archives.
........
  r57769 | thomas.wouters | 2007-08-30 23:01:17 +0200 (Thu, 30 Aug 2007) | 7 lines


  Somewhat-preliminary slice-object and extended slicing support for ctypes.
  The exact behaviour of omitted and negative indices for the Pointer type may
  need a closer look (especially as it's subtly different from simple slices)
  but there's time yet before 2.6, and not enough before 3.0a1 :-)
........
diff --git a/Lib/calendar.py b/Lib/calendar.py
index e243255..5487095 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -471,7 +471,7 @@
         a('<meta http-equiv="Content-Type" content="text/html; charset=%s" />\n' % encoding)
         if css is not None:
             a('<link rel="stylesheet" type="text/css" href="%s" />\n' % css)
-        a('<title>Calendar for %d</title\n' % theyear)
+        a('<title>Calendar for %d</title>\n' % theyear)
         a('</head>\n')
         a('<body>\n')
         a(self.formatyear(theyear, width))
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py
index e01ccfd..f487013 100644
--- a/Lib/ctypes/test/test_arrays.py
+++ b/Lib/ctypes/test/test_arrays.py
@@ -95,6 +95,10 @@
         p = create_string_buffer("foo")
         sz = (c_char * 3).from_address(addressof(p))
         self.failUnlessEqual(sz[:], "foo")
+        self.failUnlessEqual(sz[::], "foo")
+        self.failUnlessEqual(sz[::-1], "oof")
+        self.failUnlessEqual(sz[::3], "f")
+        self.failUnlessEqual(sz[1:4:2], "o")
         self.failUnlessEqual(sz.value, "foo")
 
     try:
@@ -106,6 +110,10 @@
             p = create_unicode_buffer("foo")
             sz = (c_wchar * 3).from_address(addressof(p))
             self.failUnlessEqual(sz[:], "foo")
+            self.failUnlessEqual(sz[::], "foo")
+            self.failUnlessEqual(sz[::-1], "oof")
+            self.failUnlessEqual(sz[::3], "f")
+            self.failUnlessEqual(sz[1:4:2], "o")
             self.failUnlessEqual(sz.value, "foo")
 
 if __name__ == '__main__':
diff --git a/Lib/ctypes/test/test_buffers.py b/Lib/ctypes/test/test_buffers.py
index 35c0510..5e7b23d 100644
--- a/Lib/ctypes/test/test_buffers.py
+++ b/Lib/ctypes/test/test_buffers.py
@@ -15,6 +15,10 @@
         self.failUnless(type(b[0]) is bytes)
         self.failUnlessEqual(b[0], b"a")
         self.failUnlessEqual(b[:], "abc\0")
+        self.failUnlessEqual(b[::], "abc\0")
+        self.failUnlessEqual(b[::-1], "\0cba")
+        self.failUnlessEqual(b[::2], "ac")
+        self.failUnlessEqual(b[::5], "a")
 
     def test_string_conversion(self):
         b = create_string_buffer("abc")
@@ -23,6 +27,10 @@
         self.failUnless(type(b[0]) is bytes)
         self.failUnlessEqual(b[0], b"a")
         self.failUnlessEqual(b[:], "abc\0")
+        self.failUnlessEqual(b[::], "abc\0")
+        self.failUnlessEqual(b[::-1], "\0cba")
+        self.failUnlessEqual(b[::2], "ac")
+        self.failUnlessEqual(b[::5], "a")
 
     try:
         c_wchar
@@ -41,6 +49,10 @@
             self.failUnless(type(b[0]) is str)
             self.failUnlessEqual(b[0], "a")
             self.failUnlessEqual(b[:], "abc\0")
+            self.failUnlessEqual(b[::], "abc\0")
+            self.failUnlessEqual(b[::-1], "\0cba")
+            self.failUnlessEqual(b[::2], "ac")
+            self.failUnlessEqual(b[::5], "a")
 
         def test_unicode_conversion(self):
             b = create_unicode_buffer("abc")
@@ -49,6 +61,10 @@
             self.failUnless(type(b[0]) is str)
             self.failUnlessEqual(b[0], "a")
             self.failUnlessEqual(b[:], "abc\0")
+            self.failUnlessEqual(b[::], "abc\0")
+            self.failUnlessEqual(b[::-1], "\0cba")
+            self.failUnlessEqual(b[::2], "ac")
+            self.failUnlessEqual(b[::5], "a")
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/Lib/ctypes/test/test_cast.py b/Lib/ctypes/test/test_cast.py
index cafb697..cb7524e 100644
--- a/Lib/ctypes/test/test_cast.py
+++ b/Lib/ctypes/test/test_cast.py
@@ -50,12 +50,24 @@
     def test_other(self):
         p = cast((c_int * 4)(1, 2, 3, 4), POINTER(c_int))
         self.failUnlessEqual(p[:4], [1,2, 3, 4])
+        self.failUnlessEqual(p[:4:], [1, 2, 3, 4])
+        self.failUnlessEqual(p[3:-1:-1], [4, 3, 2, 1])
+        self.failUnlessEqual(p[:4:3], [1, 4])
         c_int()
         self.failUnlessEqual(p[:4], [1, 2, 3, 4])
+        self.failUnlessEqual(p[:4:], [1, 2, 3, 4])
+        self.failUnlessEqual(p[3:-1:-1], [4, 3, 2, 1])
+        self.failUnlessEqual(p[:4:3], [1, 4])
         p[2] = 96
         self.failUnlessEqual(p[:4], [1, 2, 96, 4])
+        self.failUnlessEqual(p[:4:], [1, 2, 96, 4])
+        self.failUnlessEqual(p[3:-1:-1], [4, 96, 2, 1])
+        self.failUnlessEqual(p[:4:3], [1, 4])
         c_int()
         self.failUnlessEqual(p[:4], [1, 2, 96, 4])
+        self.failUnlessEqual(p[:4:], [1, 2, 96, 4])
+        self.failUnlessEqual(p[3:-1:-1], [4, 96, 2, 1])
+        self.failUnlessEqual(p[:4:3], [1, 4])
 
     def test_char_p(self):
         # This didn't work: bad argument to internal function
diff --git a/Lib/ctypes/test/test_memfunctions.py b/Lib/ctypes/test/test_memfunctions.py
index fcc888b..79804bf 100644
--- a/Lib/ctypes/test/test_memfunctions.py
+++ b/Lib/ctypes/test/test_memfunctions.py
@@ -30,6 +30,14 @@
         self.failUnlessEqual(cast(a, c_char_p).value, "abcdef")
         self.failUnlessEqual(cast(a, POINTER(c_byte))[:7],
                              [97, 98, 99, 100, 101, 102, 0])
+        self.failUnlessEqual(cast(a, POINTER(c_byte))[:7:],
+                             [97, 98, 99, 100, 101, 102, 0])
+        self.failUnlessEqual(cast(a, POINTER(c_byte))[6:-1:-1],
+                             [0, 102, 101, 100, 99, 98, 97])
+        self.failUnlessEqual(cast(a, POINTER(c_byte))[:7:2],
+                             [97, 99, 101, 0])
+        self.failUnlessEqual(cast(a, POINTER(c_byte))[:7:7],
+                             [97])
 
     def test_string_at(self):
         s = string_at(b"foo bar")
diff --git a/Lib/ctypes/test/test_slicing.py b/Lib/ctypes/test/test_slicing.py
index 887475e..5df0019 100644
--- a/Lib/ctypes/test/test_slicing.py
+++ b/Lib/ctypes/test/test_slicing.py
@@ -8,13 +8,22 @@
         a = (c_int * 100)(*range(1100, 1200))
         b = list(range(1100, 1200))
         self.failUnlessEqual(a[0:2], b[0:2])
+        self.failUnlessEqual(a[0:2:], b[0:2:])
         self.failUnlessEqual(len(a), len(b))
         self.failUnlessEqual(a[5:7], b[5:7])
+        self.failUnlessEqual(a[5:7:], b[5:7:])
         self.failUnlessEqual(a[-1], b[-1])
         self.failUnlessEqual(a[:], b[:])
+        self.failUnlessEqual(a[::], b[::])
+        self.failUnlessEqual(a[10::-1], b[10::-1])
+        self.failUnlessEqual(a[30:20:-1], b[30:20:-1])
+        self.failUnlessEqual(a[:12:6], b[:12:6])
+        self.failUnlessEqual(a[2:6:4], b[2:6:4])
 
         a[0:5] = range(5, 10)
         self.failUnlessEqual(a[0:5], list(range(5, 10)))
+        self.failUnlessEqual(a[0:5:], list(range(5, 10)))
+        self.failUnlessEqual(a[4::-1], list(range(9, 4, -1)))
 
     def test_setslice_cint(self):
         a = (c_int * 100)(*range(1100, 1200))
@@ -22,17 +31,36 @@
 
         a[32:47] = list(range(32, 47))
         self.failUnlessEqual(a[32:47], list(range(32, 47)))
+        a[32:47] = range(132, 147)
+        self.failUnlessEqual(a[32:47:], list(range(132, 147)))
+        a[46:31:-1] = range(232, 247)
+        self.failUnlessEqual(a[32:47:1], list(range(246, 231, -1)))
 
-        from operator import setslice
+        a[32:47] = range(1132, 1147)
+        self.failUnlessEqual(a[:], b)
+        a[32:47:7] = range(3)
+        b[32:47:7] = range(3)
+        self.failUnlessEqual(a[:], b)
+        a[33::-3] = range(12)
+        b[33::-3] = range(12)
+        self.failUnlessEqual(a[:], b)
+
+        from operator import setslice, setitem
 
         # TypeError: int expected instead of str instance
         self.assertRaises(TypeError, setslice, a, 0, 5, "abcde")
+        self.assertRaises(TypeError, setitem, a, slice(0, 5), "abcde")
         # TypeError: int expected instead of str instance
         self.assertRaises(TypeError, setslice, a, 0, 5, ["a", "b", "c", "d", "e"])
+        self.assertRaises(TypeError, setitem, a, slice(0, 5),
+                          ["a", "b", "c", "d", "e"])
         # TypeError: int expected instead of float instance
         self.assertRaises(TypeError, setslice, a, 0, 5, [1, 2, 3, 4, 3.14])
+        self.assertRaises(TypeError, setitem, a, slice(0, 5),
+                          [1, 2, 3, 4, 3.14])
         # ValueError: Can only assign sequence of same size
         self.assertRaises(ValueError, setslice, a, 0, 5, range(32))
+        self.assertRaises(ValueError, setitem, a, slice(0, 5), range(32))
 
     def test_char_ptr(self):
         s = b"abcdefghijklmnopqrstuvwxyz"
@@ -42,15 +70,32 @@
         dll.my_free.restype = None
         res = dll.my_strdup(s)
         self.failUnlessEqual(res[:len(s)], s)
+        self.failUnlessEqual(res[:3], s[:3])
+        self.failUnlessEqual(res[:len(s):], s)
+        self.failUnlessEqual(res[len(s)-1:-1:-1], s[::-1])
+        self.failUnlessEqual(res[len(s)-1:5:-7], s[:5:-7])
+        self.failUnlessEqual(res[0:-1:-1], s[0::-1])
 
         import operator
+        self.assertRaises(ValueError, operator.getitem,
+                          res, slice(None, None, None))
+        self.assertRaises(ValueError, operator.getitem,
+                          res, slice(0, None, None))
+        self.assertRaises(ValueError, operator.getitem,
+                          res, slice(None, 5, -1))
+        self.assertRaises(ValueError, operator.getitem,
+                          res, slice(-5, None, None))
+
         self.assertRaises(TypeError, operator.setslice,
                           res, 0, 5, "abcde")
+        self.assertRaises(TypeError, operator.setitem,
+                          res, slice(0, 5), "abcde")
         dll.my_free(res)
 
         dll.my_strdup.restype = POINTER(c_byte)
         res = dll.my_strdup(s)
         self.failUnlessEqual(res[:len(s)], list(range(ord("a"), ord("z")+1)))
+        self.failUnlessEqual(res[:len(s):], list(range(ord("a"), ord("z")+1)))
         dll.my_free(res)
 
     def test_char_ptr_with_free(self):
@@ -80,6 +125,10 @@
 
         p = (c_char * 27)(*s)
         self.failUnlessEqual(p[:], s)
+        self.failUnlessEqual(p[::], s)
+        self.failUnlessEqual(p[::-1], s[::-1])
+        self.failUnlessEqual(p[5::-2], s[5::-2])
+        self.failUnlessEqual(p[2:5:-3], s[2:5:-3])
 
 
     try:
@@ -96,10 +145,15 @@
             dll.my_free.restype = None
             res = dll.my_wcsdup(s)
             self.failUnlessEqual(res[:len(s)], s)
+            self.failUnlessEqual(res[:len(s):], s)
+            self.failUnlessEqual(res[len(s)-1:-1:-1], s[::-1])
+            self.failUnlessEqual(res[len(s)-1:5:-7], s[:5:-7])
 
             import operator
             self.assertRaises(TypeError, operator.setslice,
                               res, 0, 5, "abcde")
+            self.assertRaises(TypeError, operator.setitem,
+                              res, slice(0, 5), "abcde")
             dll.my_free(res)
 
             if sizeof(c_wchar) == sizeof(c_short):
@@ -111,8 +165,11 @@
             else:
                 return
             res = dll.my_wcsdup(s)
-            self.failUnlessEqual(res[:len(s)-1],
-                                 list(range(ord("a"), ord("z")+1)))
+            tmpl = list(range(ord("a"), ord("z")+1))
+            self.failUnlessEqual(res[:len(s)-1], tmpl)
+            self.failUnlessEqual(res[:len(s)-1:], tmpl)
+            self.failUnlessEqual(res[len(s)-2:-1:-1], tmpl[::-1])
+            self.failUnlessEqual(res[len(s)-2:5:-7], tmpl[:5:-7])
             dll.my_free(res)
 
 ################################################################
diff --git a/Lib/ctypes/test/test_strings.py b/Lib/ctypes/test/test_strings.py
index 17c78a0..ad3c49e 100644
--- a/Lib/ctypes/test/test_strings.py
+++ b/Lib/ctypes/test/test_strings.py
@@ -121,6 +121,9 @@
     def XX_test_initialized_strings(self):
 
         self.failUnless(c_string("ab", 4).raw[:2] == "ab")
+        self.failUnless(c_string("ab", 4).raw[:2:] == "ab")
+        self.failUnless(c_string("ab", 4).raw[:2:-1] == "ba")
+        self.failUnless(c_string("ab", 4).raw[:2:2] == "a")
         self.failUnless(c_string("ab", 4).raw[-1] == "\000")
         self.failUnless(c_string("ab", 2).raw == "a\000")
 
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 0aa4aea..b50e4df 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -236,7 +236,13 @@
 
         # can use tuple to initialize array (but not list!)
         self.failUnlessEqual(SomeInts((1, 2)).a[:], [1, 2, 0, 0])
+        self.failUnlessEqual(SomeInts((1, 2)).a[::], [1, 2, 0, 0])
+        self.failUnlessEqual(SomeInts((1, 2)).a[::-1], [0, 0, 2, 1])
+        self.failUnlessEqual(SomeInts((1, 2)).a[::2], [1, 0])
+        self.failUnlessEqual(SomeInts((1, 2)).a[1:5:6], [2])
+        self.failUnlessEqual(SomeInts((1, 2)).a[6:4:-1], [])
         self.failUnlessEqual(SomeInts((1, 2, 3, 4)).a[:], [1, 2, 3, 4])
+        self.failUnlessEqual(SomeInts((1, 2, 3, 4)).a[::], [1, 2, 3, 4])
         # too long
         # XXX Should raise ValueError?, not RuntimeError
         self.assertRaises(RuntimeError, SomeInts, (1, 2, 3, 4, 5))
diff --git a/Lib/ctypes/test/test_unicode.py b/Lib/ctypes/test/test_unicode.py
index bf5486c..717805e 100644
--- a/Lib/ctypes/test/test_unicode.py
+++ b/Lib/ctypes/test/test_unicode.py
@@ -58,11 +58,19 @@
             ctypes.set_conversion_mode("ascii", "replace")
             buf = ctypes.create_unicode_buffer(b"ab\xe4\xf6\xfc")
             self.failUnlessEqual(buf[:], "ab\uFFFD\uFFFD\uFFFD\0")
+            self.failUnlessEqual(buf[::], "ab\uFFFD\uFFFD\uFFFD\0")
+            self.failUnlessEqual(buf[::-1], "\0\uFFFD\uFFFD\uFFFDba")
+            self.failUnlessEqual(buf[::2], "a\uFFFD\uFFFD")
+            self.failUnlessEqual(buf[6:5:-1], "")
 
             ctypes.set_conversion_mode("ascii", "ignore")
             buf = ctypes.create_unicode_buffer(b"ab\xe4\xf6\xfc")
             # is that correct? not sure.  But with 'ignore', you get what you pay for..
             self.failUnlessEqual(buf[:], "ab\0\0\0\0")
+            self.failUnlessEqual(buf[::], "ab\0\0\0\0")
+            self.failUnlessEqual(buf[::-1], "\0\0\0\0ba")
+            self.failUnlessEqual(buf[::2], "a\0\0")
+            self.failUnlessEqual(buf[6:5:-1], "")
 
     import _ctypes_test
     func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
@@ -104,11 +112,17 @@
             ctypes.set_conversion_mode("ascii", "replace")
             buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc")
             self.failUnlessEqual(buf[:], "ab???\0")
+            self.failUnlessEqual(buf[::], "ab???\0")
+            self.failUnlessEqual(buf[::-1], "\0???ba")
+            self.failUnlessEqual(buf[::2], "a??")
+            self.failUnlessEqual(buf[6:5:-1], "")
 
             ctypes.set_conversion_mode("ascii", "ignore")
             buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc")
             # is that correct? not sure.  But with 'ignore', you get what you pay for..
             self.failUnlessEqual(buf[:], "ab\0\0\0\0")
+            self.failUnlessEqual(buf[::], "ab\0\0\0\0")
+            self.failUnlessEqual(buf[::-1], "\0\0\0\0ba")
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 9887540..a6ac4e3 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -72,7 +72,7 @@
 import socket
 from urlparse import urlsplit
 
-__all__ = ["HTTPResponse", "HTTPConnection", "HTTPSConnection",
+__all__ = ["HTTPResponse", "HTTPConnection",
            "HTTPException", "NotConnected", "UnknownProtocol",
            "UnknownTransferEncoding", "UnimplementedFileMode",
            "IncompleteRead", "InvalidURL", "ImproperConnectionState",
@@ -964,207 +964,33 @@
 
         return response
 
-# The next several classes are used to define FakeSocket, a socket-like
-# interface to an SSL connection.
+try:
+    import ssl
+except ImportError:
+    pass
+else:
+    class HTTPSConnection(HTTPConnection):
+        "This class allows communication via SSL."
 
-# The primary complexity comes from faking a makefile() method.  The
-# standard socket makefile() implementation calls dup() on the socket
-# file descriptor.  As a consequence, clients can call close() on the
-# parent socket and its makefile children in any order.  The underlying
-# socket isn't closed until they are all closed.
+        default_port = HTTPS_PORT
 
-# The implementation uses reference counting to keep the socket open
-# until the last client calls close().  SharedSocket keeps track of
-# the reference counting and SharedSocketClient provides an constructor
-# and close() method that call incref() and decref() correctly.
+        def __init__(self, host, port=None, key_file=None, cert_file=None,
+                     strict=None, timeout=None):
+            HTTPConnection.__init__(self, host, port, strict, timeout)
+            self.key_file = key_file
+            self.cert_file = cert_file
 
-class SharedSocket:
+        def connect(self):
+            "Connect to a host on a given (SSL) port."
 
-    def __init__(self, sock):
-        self.sock = sock
-        self._refcnt = 0
+            sock = socket.create_connection((self.host, self.port), self.timeout)
+            self.sock = ssl.sslsocket(sock, self.key_file, self.cert_file)
 
-    def incref(self):
-        self._refcnt += 1
 
-    def decref(self):
-        self._refcnt -= 1
-        assert self._refcnt >= 0
-        if self._refcnt == 0:
-            self.sock.close()
+    def FakeSocket (sock, sslobj):
+        return sslobj
 
-    def __del__(self):
-        self.sock.close()
-
-class SharedSocketClient:
-
-    def __init__(self, shared):
-        self._closed = 0
-        self._shared = shared
-        self._shared.incref()
-        self._sock = shared.sock
-
-    def close(self):
-        if not self._closed:
-            self._shared.decref()
-            self._closed = 1
-            self._shared = None
-
-class SSLFile(SharedSocketClient):
-    """File-like object wrapping an SSL socket."""
-
-    BUFSIZE = 8192
-
-    def __init__(self, sock, ssl, bufsize=None):
-        SharedSocketClient.__init__(self, sock)
-        self._ssl = ssl
-        self._buf = b""
-        self._bufsize = bufsize or self.__class__.BUFSIZE
-
-    def _read(self):
-        buf = b""
-        # put in a loop so that we retry on transient errors
-        while True:
-            try:
-                buf = self._ssl.read(self._bufsize)
-            except socket.sslerror as err:
-                err_type = err.args[0]
-                if (err_type == socket.SSL_ERROR_WANT_READ
-                    or err_type == socket.SSL_ERROR_WANT_WRITE):
-                    continue
-                if (err_type == socket.SSL_ERROR_ZERO_RETURN
-                    or err_type == socket.SSL_ERROR_EOF):
-                    break
-                raise
-            except socket.error as err:
-                err_type = err.args[0]
-                if err_type == errno.EINTR:
-                    continue
-                if err_type == errno.EBADF:
-                    # XXX socket was closed?
-                    break
-                raise
-            else:
-                break
-        return buf
-
-    def read(self, size=None):
-        L = [self._buf]
-        avail = len(self._buf)
-        while size is None or avail < size:
-            s = self._read()
-            if s == b"":
-                break
-            L.append(s)
-            avail += len(s)
-        all = b"".join(L)
-        if size is None:
-            self._buf = b""
-            return all
-        else:
-            self._buf = all[size:]
-            return all[:size]
-
-    def readline(self):
-        L = [self._buf]
-        self._buf = b""
-        while 1:
-            i = L[-1].find("\n")
-            if i >= 0:
-                break
-            s = self._read()
-            if s == b"":
-                break
-            L.append(s)
-        if i == -1:
-            # loop exited because there is no more data
-            return b"".join(L)
-        else:
-            all = b"".join(L)
-            # XXX could do enough bookkeeping not to do a 2nd search
-            i = all.find("\n") + 1
-            line = all[:i]
-            self._buf = all[i:]
-            return line
-
-    def readlines(self, sizehint=0):
-        total = 0
-        list = []
-        while True:
-            line = self.readline()
-            if not line:
-                break
-            list.append(line)
-            total += len(line)
-            if sizehint and total >= sizehint:
-                break
-        return list
-
-    def fileno(self):
-        return self._sock.fileno()
-
-    def __iter__(self):
-        return self
-
-    def __next__(self):
-        line = self.readline()
-        if not line:
-            raise StopIteration
-        return line
-
-class FakeSocket(SharedSocketClient):
-
-    class _closedsocket:
-        def __getattr__(self, name):
-            raise error(9, 'Bad file descriptor')
-
-    def __init__(self, sock, ssl):
-        sock = SharedSocket(sock)
-        SharedSocketClient.__init__(self, sock)
-        self._ssl = ssl
-
-    def close(self):
-        SharedSocketClient.close(self)
-        self._sock = self.__class__._closedsocket()
-
-    def makefile(self, mode, bufsize=None):
-        if mode != 'r' and mode != 'rb':
-            raise UnimplementedFileMode()
-        return SSLFile(self._shared, self._ssl, bufsize)
-
-    def send(self, stuff, flags = 0):
-        return self._ssl.write(stuff)
-
-    sendall = send
-
-    def recv(self, len = 1024, flags = 0):
-        return self._ssl.read(len)
-
-    def __getattr__(self, attr):
-        return getattr(self._sock, attr)
-
-    def close(self):
-        SharedSocketClient.close(self)
-        self._ssl = None
-
-class HTTPSConnection(HTTPConnection):
-    "This class allows communication via SSL."
-
-    default_port = HTTPS_PORT
-
-    def __init__(self, host, port=None, key_file=None, cert_file=None,
-                 strict=None, timeout=None):
-        HTTPConnection.__init__(self, host, port, strict, timeout)
-        self.key_file = key_file
-        self.cert_file = cert_file
-
-    def connect(self):
-        "Connect to a host on a given (SSL) port."
-
-        sock = socket.create_connection((self.host, self.port), self.timeout)
-        ssl = socket.ssl(sock, self.key_file, self.cert_file)
-        self.sock = FakeSocket(sock, ssl)
-
+    __all__.append("HTTPSConnection")
 
 class HTTPException(Exception):
     # Subclasses that define an __init__ must call Exception.__init__
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index 2df533f..0a97372 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -24,7 +24,7 @@
 
 import binascii, os, random, re, socket, sys, time
 
-__all__ = ["IMAP4", "IMAP4_SSL", "IMAP4_stream", "Internaldate2tuple",
+__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple",
            "Int2AP", "ParseFlags", "Time2Internaldate"]
 
 #       Globals
@@ -1111,95 +1111,101 @@
 
 
 
-class IMAP4_SSL(IMAP4):
+try:
+    import ssl
+except ImportError:
+    pass
+else:
+    class IMAP4_SSL(IMAP4):
 
-    """IMAP4 client class over SSL connection
+        """IMAP4 client class over SSL connection
 
-    Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile]]]])
+        Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile]]]])
 
-            host - host's name (default: localhost);
-            port - port number (default: standard IMAP4 SSL port).
-            keyfile - PEM formatted file that contains your private key (default: None);
-            certfile - PEM formatted certificate chain file (default: None);
+                host - host's name (default: localhost);
+                port - port number (default: standard IMAP4 SSL port).
+                keyfile - PEM formatted file that contains your private key (default: None);
+                certfile - PEM formatted certificate chain file (default: None);
 
-    for more documentation see the docstring of the parent class IMAP4.
-    """
-
-
-    def __init__(self, host = '', port = IMAP4_SSL_PORT, keyfile = None, certfile = None):
-        self.keyfile = keyfile
-        self.certfile = certfile
-        IMAP4.__init__(self, host, port)
-
-
-    def open(self, host = '', port = IMAP4_SSL_PORT):
-        """Setup connection to remote server on "host:port".
-            (default: localhost:standard IMAP4 SSL port).
-        This connection will be used by the routines:
-            read, readline, send, shutdown.
+        for more documentation see the docstring of the parent class IMAP4.
         """
-        self.host = host
-        self.port = port
-        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        self.sock.connect((host, port))
-        self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
 
 
-    def read(self, size):
-        """Read 'size' bytes from remote."""
-        # sslobj.read() sometimes returns < size bytes
-        chunks = []
-        read = 0
-        while read < size:
-            data = self.sslobj.read(size-read)
-            read += len(data)
-            chunks.append(data)
-
-        return ''.join(chunks)
+        def __init__(self, host = '', port = IMAP4_SSL_PORT, keyfile = None, certfile = None):
+            self.keyfile = keyfile
+            self.certfile = certfile
+            IMAP4.__init__(self, host, port)
 
 
-    def readline(self):
-        """Read line from remote."""
-        # NB: socket.ssl needs a "readline" method, or perhaps a "makefile" method.
-        line = []
-        while 1:
-            char = self.sslobj.read(1)
-            line.append(char)
-            if char == "\n": return ''.join(line)
+        def open(self, host = '', port = IMAP4_SSL_PORT):
+            """Setup connection to remote server on "host:port".
+                (default: localhost:standard IMAP4 SSL port).
+            This connection will be used by the routines:
+                read, readline, send, shutdown.
+            """
+            self.host = host
+            self.port = port
+            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            self.sock.connect((host, port))
+            self.sslobj = ssl.sslsocket(self.sock, self.keyfile, self.certfile)
 
 
-    def send(self, data):
-        """Send data to remote."""
-        # NB: socket.ssl needs a "sendall" method to match socket objects.
-        bytes = len(data)
-        while bytes > 0:
-            sent = self.sslobj.write(data)
-            if sent == bytes:
-                break    # avoid copy
-            data = data[sent:]
-            bytes = bytes - sent
+        def read(self, size):
+            """Read 'size' bytes from remote."""
+            # sslobj.read() sometimes returns < size bytes
+            chunks = []
+            read = 0
+            while read < size:
+                data = self.sslobj.read(size-read)
+                read += len(data)
+                chunks.append(data)
+
+            return ''.join(chunks)
 
 
-    def shutdown(self):
-        """Close I/O established in "open"."""
-        self.sock.close()
+        def readline(self):
+            """Read line from remote."""
+            # NB: socket.ssl needs a "readline" method, or perhaps a "makefile" method.
+            line = []
+            while 1:
+                char = self.sslobj.read(1)
+                line.append(char)
+                if char == "\n": return ''.join(line)
 
 
-    def socket(self):
-        """Return socket instance used to connect to IMAP4 server.
-
-        socket = <instance>.socket()
-        """
-        return self.sock
+        def send(self, data):
+            """Send data to remote."""
+            # NB: socket.ssl needs a "sendall" method to match socket objects.
+            bytes = len(data)
+            while bytes > 0:
+                sent = self.sslobj.write(data)
+                if sent == bytes:
+                    break    # avoid copy
+                data = data[sent:]
+                bytes = bytes - sent
 
 
-    def ssl(self):
-        """Return SSLObject instance used to communicate with the IMAP4 server.
+        def shutdown(self):
+            """Close I/O established in "open"."""
+            self.sock.close()
 
-        ssl = <instance>.socket.ssl()
-        """
-        return self.sslobj
 
+        def socket(self):
+            """Return socket instance used to connect to IMAP4 server.
+
+            socket = <instance>.socket()
+            """
+            return self.sock
+
+
+        def ssl(self):
+            """Return SSLObject instance used to communicate with the IMAP4 server.
+
+            ssl = <instance>.socket.ssl()
+            """
+            return self.sslobj
+
+    __all__.append("IMAP4_SSL")
 
 
 class IMAP4_stream(IMAP4):
diff --git a/Lib/pipes.py b/Lib/pipes.py
index dc18404..6a473ae 100644
--- a/Lib/pipes.py
+++ b/Lib/pipes.py
@@ -60,7 +60,6 @@
 
 
 import re
-
 import os
 import tempfile
 import string
@@ -267,18 +266,3 @@
             c = '\\' + c
         res = res + c
     return '"' + res + '"'
-
-
-# Small test program and example
-
-def test():
-    print('Testing...')
-    t = Template()
-    t.append('togif $IN $OUT', 'ff')
-    t.append('giftoppm', '--')
-    t.append('ppmtogif >$OUT', '-f')
-    t.append('fromgif $IN $OUT', 'ff')
-    t.debug(1)
-    FILE = '/usr/local/images/rgb/rogues/guido.rgb'
-    t.copy(FILE, '@temp')
-    print('Done.')
diff --git a/Lib/poplib.py b/Lib/poplib.py
index ef60c74..323d915 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -15,7 +15,7 @@
 
 import re, socket
 
-__all__ = ["POP3","error_proto","POP3_SSL"]
+__all__ = ["POP3","error_proto"]
 
 # Exception raised when an error or invalid response is received:
 
@@ -307,90 +307,97 @@
             return self._shortcmd('UIDL %s' % which)
         return self._longcmd('UIDL')
 
-class POP3_SSL(POP3):
-    """POP3 client class over SSL connection
+try:
+    import ssl
+except ImportError:
+    pass
+else:
 
-    Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=None)
+    class POP3_SSL(POP3):
+        """POP3 client class over SSL connection
 
-           hostname - the hostname of the pop3 over ssl server
-           port - port number
-           keyfile - PEM formatted file that countains your private key
-           certfile - PEM formatted certificate chain file
+        Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=None)
 
-        See the methods of the parent class POP3 for more documentation.
-    """
+               hostname - the hostname of the pop3 over ssl server
+               port - port number
+               keyfile - PEM formatted file that countains your private key
+               certfile - PEM formatted certificate chain file
 
-    def __init__(self, host, port = POP3_SSL_PORT, keyfile = None, certfile = None):
-        self.host = host
-        self.port = port
-        self.keyfile = keyfile
-        self.certfile = certfile
-        self.buffer = ""
-        msg = "getaddrinfo returns an empty list"
-        self.sock = None
-        for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
-            af, socktype, proto, canonname, sa = res
-            try:
-                self.sock = socket.socket(af, socktype, proto)
-                self.sock.connect(sa)
-            except socket.error as msg:
-                if self.sock:
-                    self.sock.close()
-                self.sock = None
-                continue
-            break
-        if not self.sock:
-            raise socket.error(msg)
-        self.file = self.sock.makefile('rb')
-        self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
-        self._debugging = 0
-        self.welcome = self._getresp()
+            See the methods of the parent class POP3 for more documentation.
+        """
 
-    def _fillBuffer(self):
-        localbuf = self.sslobj.read()
-        if len(localbuf) == 0:
-            raise error_proto('-ERR EOF')
-        self.buffer += localbuf
+        def __init__(self, host, port = POP3_SSL_PORT, keyfile = None, certfile = None):
+            self.host = host
+            self.port = port
+            self.keyfile = keyfile
+            self.certfile = certfile
+            self.buffer = ""
+            msg = "getaddrinfo returns an empty list"
+            self.sock = None
+            for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
+                af, socktype, proto, canonname, sa = res
+                try:
+                    self.sock = socket.socket(af, socktype, proto)
+                    self.sock.connect(sa)
+                except socket.error as msg:
+                    if self.sock:
+                        self.sock.close()
+                    self.sock = None
+                    continue
+                break
+            if not self.sock:
+                raise socket.error(msg)
+            self.file = self.sock.makefile('rb')
+            self.sslobj = ssl.sslsocket(self.sock, self.keyfile, self.certfile)
+            self._debugging = 0
+            self.welcome = self._getresp()
 
-    def _getline(self):
-        line = ""
-        renewline = re.compile(r'.*?\n')
-        match = renewline.match(self.buffer)
-        while not match:
-            self._fillBuffer()
+        def _fillBuffer(self):
+            localbuf = self.sslobj.read()
+            if len(localbuf) == 0:
+                raise error_proto('-ERR EOF')
+            self.buffer += localbuf
+
+        def _getline(self):
+            line = ""
+            renewline = re.compile(r'.*?\n')
             match = renewline.match(self.buffer)
-        line = match.group(0)
-        self.buffer = renewline.sub('' ,self.buffer, 1)
-        if self._debugging > 1: print('*get*', repr(line))
+            while not match:
+                self._fillBuffer()
+                match = renewline.match(self.buffer)
+            line = match.group(0)
+            self.buffer = renewline.sub('' ,self.buffer, 1)
+            if self._debugging > 1: print('*get*', repr(line))
 
-        octets = len(line)
-        if line[-2:] == CRLF:
-            return line[:-2], octets
-        if line[0] == CR:
-            return line[1:-1], octets
-        return line[:-1], octets
+            octets = len(line)
+            if line[-2:] == CRLF:
+                return line[:-2], octets
+            if line[0] == CR:
+                return line[1:-1], octets
+            return line[:-1], octets
 
-    def _putline(self, line):
-        if self._debugging > 1: print('*put*', repr(line))
-        line += CRLF
-        bytes = len(line)
-        while bytes > 0:
-            sent = self.sslobj.write(line)
-            if sent == bytes:
-                break    # avoid copy
-            line = line[sent:]
-            bytes = bytes - sent
+        def _putline(self, line):
+            if self._debugging > 1: print('*put*', repr(line))
+            line += CRLF
+            bytes = len(line)
+            while bytes > 0:
+                sent = self.sslobj.write(line)
+                if sent == bytes:
+                    break    # avoid copy
+                line = line[sent:]
+                bytes = bytes - sent
 
-    def quit(self):
-        """Signoff: commit changes on server, unlock mailbox, close connection."""
-        try:
-            resp = self._shortcmd('QUIT')
-        except error_proto as val:
-            resp = val
-        self.sock.close()
-        del self.sslobj, self.sock
-        return resp
+        def quit(self):
+            """Signoff: commit changes on server, unlock mailbox, close connection."""
+            try:
+                resp = self._shortcmd('QUIT')
+            except error_proto as val:
+                resp = val
+            self.sock.close()
+            del self.sslobj, self.sock
+            return resp
 
+    __all__.append("POP3_SSL")
 
 if __name__ == "__main__":
     import sys
diff --git a/Lib/robotparser.py b/Lib/robotparser.py
index 32aba46..638a261 100644
--- a/Lib/robotparser.py
+++ b/Lib/robotparser.py
@@ -230,6 +230,11 @@
         urllib.FancyURLopener.__init__(self, *args)
         self.errcode = 200
 
+    def prompt_user_passwd(self, host, realm):
+        ## If robots.txt file is accessible only with a password,
+        ## we act as if the file wasn't there.
+        return None, None
+
     def http_error_default(self, url, fp, errcode, errmsg, headers):
         self.errcode = errcode
         return urllib.FancyURLopener.http_error_default(self, url, fp, errcode,
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 1aa83a4..7423ae0 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -52,7 +52,7 @@
 __all__ = ["SMTPException","SMTPServerDisconnected","SMTPResponseException",
            "SMTPSenderRefused","SMTPRecipientsRefused","SMTPDataError",
            "SMTPConnectError","SMTPHeloError","SMTPAuthenticationError",
-           "quoteaddr","quotedata","SMTP","SMTP_SSL"]
+           "quoteaddr","quotedata","SMTP"]
 
 SMTP_PORT = 25
 SMTP_SSL_PORT = 465
@@ -128,43 +128,6 @@
     combination provided.
     """
 
-class SSLFakeSocket:
-    """A fake socket object that really wraps a SSLObject.
-
-    It only supports what is needed in smtplib.
-    """
-    def __init__(self, realsock, sslobj):
-        self.realsock = realsock
-        self.sslobj = sslobj
-
-    def send(self, str):
-        self.sslobj.write(str)
-        return len(str)
-
-    sendall = send
-
-    def close(self):
-        self.realsock.close()
-
-class SSLFakeFile:
-    """A fake file like object that really wraps a SSLObject.
-
-    It only supports what is needed in smtplib.
-    """
-    def __init__(self, sslobj):
-        self.sslobj = sslobj
-
-    def readline(self):
-        str = ""
-        chr = None
-        while chr != "\n":
-            chr = self.sslobj.read(1)
-            str += chr
-        return str
-
-    def close(self):
-        pass
-
 def quoteaddr(addr):
     """Quote a subset of the email addresses defined by RFC 821.
 
@@ -193,6 +156,33 @@
     return re.sub(r'(?m)^\.', '..',
         re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
 
+try:
+    import ssl
+except ImportError:
+    _have_ssl = False
+else:
+
+    class SSLFakeFile:
+        """A fake file like object that really wraps a SSLObject.
+
+        It only supports what is needed in smtplib.
+        """
+        def __init__(self, sslobj):
+            self.sslobj = sslobj
+
+        def readline(self):
+            str = b""
+            chr = None
+            while chr != b"\n":
+                chr = self.sslobj.read(1)
+                str += chr
+            return str
+
+        def close(self):
+            pass
+
+    _have_ssl = True
+
 
 class SMTP:
     """This class manages a connection to an SMTP or ESMTP server.
@@ -597,9 +587,10 @@
         """
         (resp, reply) = self.docmd("STARTTLS")
         if resp == 220:
-            sslobj = socket.ssl(self.sock, keyfile, certfile)
-            self.sock = SSLFakeSocket(self.sock, sslobj)
-            self.file = SSLFakeFile(sslobj)
+            if not _have_ssl:
+                raise RuntimeError("No SSL support included in this Python")
+            self.sock = ssl.sslsocket(self.sock, keyfile, certfile)
+            self.file = SSLFakeFile(self.sock)
         return (resp, reply)
 
     def sendmail(self, from_addr, to_addrs, msg, mail_options=[],
@@ -711,27 +702,31 @@
         self.docmd("quit")
         self.close()
 
-class SMTP_SSL(SMTP):
-    """ This is a subclass derived from SMTP that connects over an SSL encrypted
-    socket (to use this class you need a socket module that was compiled with SSL
-    support). If host is not specified, '' (the local host) is used. If port is
-    omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile
-    are also optional - they can contain a PEM formatted private key and
-    certificate chain file for the SSL connection.
-    """
-    def __init__(self, host='', port=0, local_hostname=None,
-                 keyfile=None, certfile=None, timeout=None):
-        self.keyfile = keyfile
-        self.certfile = certfile
-        SMTP.__init__(self, host, port, local_hostname, timeout)
-        self.default_port = SMTP_SSL_PORT
+if _have_ssl:
 
-    def _get_socket(self, host, port, timeout):
-        if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
-        self.sock = socket.create_connection((host, port), timeout)
-        sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
-        self.sock = SSLFakeSocket(self.sock, sslobj)
-        self.file = SSLFakeFile(sslobj)
+    class SMTP_SSL(SMTP):
+        """ This is a subclass derived from SMTP that connects over an SSL encrypted
+        socket (to use this class you need a socket module that was compiled with SSL
+        support). If host is not specified, '' (the local host) is used. If port is
+        omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile
+        are also optional - they can contain a PEM formatted private key and
+        certificate chain file for the SSL connection.
+        """
+        def __init__(self, host='', port=0, local_hostname=None,
+                     keyfile=None, certfile=None, timeout=None):
+            self.keyfile = keyfile
+            self.certfile = certfile
+            SMTP.__init__(self, host, port, local_hostname, timeout)
+            self.default_port = SMTP_SSL_PORT
+
+        def _get_socket(self, host, port, timeout):
+            if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
+            self.sock = socket.create_connection((host, port), timeout)
+            sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
+            self.sock = SSLFakeSocket(self.sock, sslobj)
+            self.file = SSLFakeFile(sslobj)
+
+    __all__.append("SMTP_SSL")
 
 #
 # LMTP extension
diff --git a/Lib/socket.py b/Lib/socket.py
index fb96637..0da08ae 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -46,13 +46,35 @@
 import _socket
 from _socket import *
 
-_have_ssl = False
-## try:
-##     import _ssl
-##     from _ssl import *
-##     _have_ssl = True
-## except ImportError:
-##     pass
+try:
+    import _ssl
+    import ssl as _realssl
+except ImportError:
+    # no SSL support
+    pass
+else:
+    def ssl(sock, keyfile=None, certfile=None):
+        # we do an internal import here because the ssl
+        # module imports the socket module
+        warnings.warn("socket.ssl() is deprecated.  Use ssl.sslsocket() instead.",
+                      DeprecationWarning, stacklevel=2)
+        return _realssl.sslwrap_simple(sock, keyfile, certfile)
+
+    # we need to import the same constants we used to...
+    from _ssl import \
+         sslerror, \
+         RAND_add, \
+         RAND_egd, \
+         RAND_status, \
+         SSL_ERROR_ZERO_RETURN, \
+         SSL_ERROR_WANT_READ, \
+         SSL_ERROR_WANT_WRITE, \
+         SSL_ERROR_WANT_X509_LOOKUP, \
+         SSL_ERROR_SYSCALL, \
+         SSL_ERROR_SSL, \
+         SSL_ERROR_WANT_CONNECT, \
+         SSL_ERROR_EOF, \
+         SSL_ERROR_INVALID_ERROR_CODE
 
 import os, sys, io
 
@@ -63,12 +85,9 @@
 
 __all__ = ["getfqdn"]
 __all__.extend(os._get_exports_list(_socket))
-if _have_ssl:
-    __all__.extend(os._get_exports_list(_ssl))
-    def ssl(sock, keyfile=None, certfile=None):
-        import ssl as realssl
-        return realssl.sslwrap_simple(sock, keyfile, certfile)
-    __all__.append("ssl")
+
+
+_realsocket = socket
 
 # WSA error codes
 if sys.platform.lower().startswith("win"):
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 77a2ceb..388c931 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -60,55 +60,47 @@
 import os, sys
 
 import _ssl             # if we can't import it, let the error propagate
-from socket import socket
 from _ssl import sslerror
 from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
 from _ssl import PROTOCOL_SSLv2, PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
+from _ssl import \
+     SSL_ERROR_ZERO_RETURN, \
+     SSL_ERROR_WANT_READ, \
+     SSL_ERROR_WANT_WRITE, \
+     SSL_ERROR_WANT_X509_LOOKUP, \
+     SSL_ERROR_SYSCALL, \
+     SSL_ERROR_SSL, \
+     SSL_ERROR_WANT_CONNECT, \
+     SSL_ERROR_EOF, \
+     SSL_ERROR_INVALID_ERROR_CODE
 
-# Root certs:
-#
-# The "ca_certs" argument to sslsocket() expects a file containing one or more
-# certificates that are roots of various certificate signing chains.  This file
-# contains the certificates in PEM format (RFC ) where each certificate is
-# encoded in base64 encoding and surrounded with a header and footer:
-# -----BEGIN CERTIFICATE-----
-# ... (CA certificate in base64 encoding) ...
-# -----END CERTIFICATE-----
-# The various certificates in the file are just concatenated together:
-# -----BEGIN CERTIFICATE-----
-# ... (CA certificate in base64 encoding) ...
-# -----END CERTIFICATE-----
-# -----BEGIN CERTIFICATE-----
-# ... (a second CA certificate in base64 encoding) ...
-# -----END CERTIFICATE-----
-#
-# Some "standard" root certificates are available at
-#
-# http://www.thawte.com/roots/  (for Thawte roots)
-# http://www.verisign.com/support/roots.html  (for Verisign)
+from socket import socket
+from socket import getnameinfo as _getnameinfo
+
 
 class sslsocket (socket):
 
+    """This class implements a subtype of socket.socket that wraps
+    the underlying OS socket in an SSL context when necessary, and
+    provides read and write methods over that channel."""
+
     def __init__(self, sock, keyfile=None, certfile=None,
                  server_side=False, cert_reqs=CERT_NONE,
                  ssl_version=PROTOCOL_SSLv23, ca_certs=None):
         socket.__init__(self, _sock=sock._sock)
         if certfile and not keyfile:
             keyfile = certfile
-        if server_side:
-            self._sslobj = _ssl.sslwrap(self._sock, 1, keyfile, certfile,
-                                        cert_reqs, ssl_version, ca_certs)
+        # see if it's connected
+        try:
+            socket.getpeername(self)
+        except:
+            # no, no connection yet
+            self._sslobj = None
         else:
-            # see if it's connected
-            try:
-                socket.getpeername(self)
-            except:
-                # no, no connection yet
-                self._sslobj = None
-            else:
-                # yes, create the SSL object
-                self._sslobj = _ssl.sslwrap(self._sock, 0, keyfile, certfile,
-                                            cert_reqs, ssl_version, ca_certs)
+            # yes, create the SSL object
+            self._sslobj = _ssl.sslwrap(self._sock, server_side,
+                                        keyfile, certfile,
+                                        cert_reqs, ssl_version, ca_certs)
         self.keyfile = keyfile
         self.certfile = certfile
         self.cert_reqs = cert_reqs
@@ -116,73 +108,123 @@
         self.ca_certs = ca_certs
 
     def read(self, len=1024):
+
+        """Read up to LEN bytes and return them.
+        Return zero-length string on EOF."""
+
         return self._sslobj.read(len)
 
     def write(self, data):
+
+        """Write DATA to the underlying SSL channel.  Returns
+        number of bytes of DATA actually transmitted."""
+
         return self._sslobj.write(data)
 
     def getpeercert(self):
+
+        """Returns a formatted version of the data in the
+        certificate provided by the other end of the SSL channel.
+        Return None if no certificate was provided, {} if a
+        certificate was provided, but not validated."""
+
         return self._sslobj.peer_certificate()
 
     def send (self, data, flags=0):
-        if flags != 0:
-            raise ValueError(
-                "non-zero flags not allowed in calls to send() on %s" %
-                self.__class__)
-        return self._sslobj.write(data)
+        if self._sslobj:
+            if flags != 0:
+                raise ValueError(
+                    "non-zero flags not allowed in calls to send() on %s" %
+                    self.__class__)
+            return self._sslobj.write(data)
+        else:
+            return socket.send(self, data, flags)
 
     def send_to (self, data, addr, flags=0):
-        raise ValueError("send_to not allowed on instances of %s" %
-                         self.__class__)
+        if self._sslobj:
+            raise ValueError("send_to not allowed on instances of %s" %
+                             self.__class__)
+        else:
+            return socket.send_to(self, data, addr, flags)
 
     def sendall (self, data, flags=0):
-        if flags != 0:
-            raise ValueError(
-                "non-zero flags not allowed in calls to sendall() on %s" %
-                self.__class__)
-        return self._sslobj.write(data)
+        if self._sslobj:
+            if flags != 0:
+                raise ValueError(
+                    "non-zero flags not allowed in calls to sendall() on %s" %
+                    self.__class__)
+            return self._sslobj.write(data)
+        else:
+            return socket.sendall(self, data, flags)
 
     def recv (self, buflen=1024, flags=0):
-        if flags != 0:
-            raise ValueError(
-                "non-zero flags not allowed in calls to sendall() on %s" %
-                self.__class__)
-        return self._sslobj.read(data, buflen)
+        if self._sslobj:
+            if flags != 0:
+                raise ValueError(
+                    "non-zero flags not allowed in calls to sendall() on %s" %
+                    self.__class__)
+            return self._sslobj.read(data, buflen)
+        else:
+            return socket.recv(self, buflen, flags)
 
     def recv_from (self, addr, buflen=1024, flags=0):
-        raise ValueError("recv_from not allowed on instances of %s" %
-                         self.__class__)
+        if self._sslobj:
+            raise ValueError("recv_from not allowed on instances of %s" %
+                             self.__class__)
+        else:
+            return socket.recv_from(self, addr, buflen, flags)
 
-    def shutdown(self):
+    def ssl_shutdown(self):
+
+        """Shuts down the SSL channel over this socket (if active),
+        without closing the socket connection."""
+
         if self._sslobj:
             self._sslobj.shutdown()
             self._sslobj = None
-        else:
-            socket.shutdown(self)
+
+    def shutdown(self, how):
+        self.ssl_shutdown()
+        socket.shutdown(self, how)
 
     def close(self):
-        if self._sslobj:
-            self.shutdown()
-        else:
-            socket.close(self)
+        self.ssl_shutdown()
+        socket.close(self)
 
     def connect(self, addr):
+
+        """Connects to remote ADDR, and then wraps the connection in
+        an SSL channel."""
+
         # Here we assume that the socket is client-side, and not
         # connected at the time of the call.  We connect it, then wrap it.
-        if self._sslobj or (self.getsockname()[1] != 0):
+        if self._sslobj:
             raise ValueError("attempt to connect already-connected sslsocket!")
         socket.connect(self, addr)
-        self._sslobj = _ssl.sslwrap(self._sock, 0, self.keyfile, self.certfile,
+        self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile,
                                     self.cert_reqs, self.ssl_version,
                                     self.ca_certs)
 
     def accept(self):
-        raise ValueError("accept() not supported on an sslsocket")
+
+        """Accepts a new connection from a remote client, and returns
+        a tuple containing that new connection wrapped with a server-side
+        SSL channel, and the address of the remote client."""
+
+        newsock, addr = socket.accept(self)
+        return (sslsocket(newsock, True, self.keyfile, self.certfile,
+                         self.cert_reqs, self.ssl_version,
+                         self.ca_certs), addr)
 
 
 # some utility functions
 
 def cert_time_to_seconds(cert_time):
+
+    """Takes a date-time string in standard ASN1_print form
+    ("MON DAY 24HOUR:MINUTE:SEC YEAR TIMEZONE") and return
+    a Python time value in seconds past the epoch."""
+
     import time
     return time.mktime(time.strptime(cert_time, "%b %d %H:%M:%S %Y GMT"))
 
@@ -190,66 +232,9 @@
 
 def sslwrap_simple (sock, keyfile=None, certfile=None):
 
+    """A replacement for the old socket.ssl function.  Designed
+    for compability with Python 2.5 and earlier.  Will disappear in
+    Python 3.0."""
+
     return _ssl.sslwrap(sock._sock, 0, keyfile, certfile, CERT_NONE,
                         PROTOCOL_SSLv23, None)
-
-# fetch the certificate that the server is providing in PEM form
-
-def fetch_server_certificate (host, port):
-
-    import re, tempfile, os
-
-    def subproc(cmd):
-        from subprocess import Popen, PIPE, STDOUT
-        proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
-        status = proc.wait()
-        output = proc.stdout.read()
-        return status, output
-
-    def strip_to_x509_cert(certfile_contents, outfile=None):
-        m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n"
-                      r".*[\r]*^[-]+END CERTIFICATE[-]+)$",
-                      certfile_contents, re.MULTILINE | re.DOTALL)
-        if not m:
-            return None
-        else:
-            tn = tempfile.mktemp()
-            fp = open(tn, "w")
-            fp.write(m.group(1) + "\n")
-            fp.close()
-            try:
-                tn2 = (outfile or tempfile.mktemp())
-                status, output = subproc(r'openssl x509 -in "%s" -out "%s"' %
-                                         (tn, tn2))
-                if status != 0:
-                    raise OperationError(status, tsig, output)
-                fp = open(tn2, 'rb')
-                data = fp.read()
-                fp.close()
-                os.unlink(tn2)
-                return data
-            finally:
-                os.unlink(tn)
-
-    if sys.platform.startswith("win"):
-        tfile = tempfile.mktemp()
-        fp = open(tfile, "w")
-        fp.write("quit\n")
-        fp.close()
-        try:
-            status, output = subproc(
-                'openssl s_client -connect "%s:%s" -showcerts < "%s"' %
-                (host, port, tfile))
-        finally:
-            os.unlink(tfile)
-    else:
-        status, output = subproc(
-            'openssl s_client -connect "%s:%s" -showcerts < /dev/null' %
-            (host, port))
-    if status != 0:
-        raise OSError(status)
-    certtext = strip_to_x509_cert(output)
-    if not certtext:
-        raise ValueError("Invalid response received from server at %s:%s" %
-                         (host, port))
-    return certtext
diff --git a/Lib/test/crashers/file_threads.py b/Lib/test/crashers/file_threads.py
new file mode 100644
index 0000000..d82ad3c
--- /dev/null
+++ b/Lib/test/crashers/file_threads.py
@@ -0,0 +1,8 @@
+# An example for http://bugs.python.org/issue815646
+
+import thread
+
+while 1:
+    f = open("/tmp/dupa", "w")
+    thread.start_new_thread(f.close, ())
+    f.close()
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index d26d618..552f14e 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -862,6 +862,7 @@
         test_mhlib
         test_openpty
         test_ossaudiodev
+        test_pipes
         test_poll
         test_posix
         test_pty
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index 015b59f..5f9c057 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -49,7 +49,7 @@
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ascii" />
 <link rel="stylesheet" type="text/css" href="calendar.css" />
-<title>Calendar for 2004</title
+<title>Calendar for 2004</title>
 </head>
 <body>
 <table border="0" cellpadding="0" cellspacing="0" class="year">
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index a3eb61b..05932f5 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -235,10 +235,20 @@
     # Restrict test to Win32, since there is no guarantee other
     # systems support centiseconds
     if sys.platform == 'win32':
-        def test_1565150(self):
-            t1 = 1159195039.25
-            os.utime(self.fname, (t1, t1))
-            self.assertEquals(os.stat(self.fname).st_mtime, t1)
+        def get_file_system(path):
+            import os
+            root = os.path.splitdrive(os.path.realpath("."))[0] + '\\'
+            import ctypes
+            kernel32 = ctypes.windll.kernel32
+            buf = ctypes.create_string_buffer("", 100)
+            if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)):
+                return buf.value
+
+        if get_file_system(test_support.TESTFN) == "NTFS":
+            def test_1565150(self):
+                t1 = 1159195039.25
+                os.utime(self.fname, (t1, t1))
+                self.assertEquals(os.stat(self.fname).st_mtime, t1)
 
         def test_1686475(self):
             # Verify that an open file can be stat'ed
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
new file mode 100644
index 0000000..94c2231
--- /dev/null
+++ b/Lib/test/test_pipes.py
@@ -0,0 +1,187 @@
+import pipes
+import os
+import string
+import unittest
+from test.test_support import TESTFN, run_unittest, unlink, TestSkipped
+
+if os.name != 'posix':
+    raise TestSkipped('pipes module only works on posix')
+
+TESTFN2 = TESTFN + "2"
+
+class SimplePipeTests(unittest.TestCase):
+    def tearDown(self):
+        for f in (TESTFN, TESTFN2):
+            unlink(f)
+
+    def testSimplePipe1(self):
+        t = pipes.Template()
+        t.append('tr a-z A-Z', pipes.STDIN_STDOUT)
+        f = t.open(TESTFN, 'w')
+        f.write('hello world #1')
+        f.close()
+        self.assertEqual(open(TESTFN).read(), 'HELLO WORLD #1')
+
+    def testSimplePipe2(self):
+        open(TESTFN, 'w').write('hello world #2')
+        t = pipes.Template()
+        t.append('tr a-z A-Z < $IN > $OUT', pipes.FILEIN_FILEOUT)
+        t.copy(TESTFN, TESTFN2)
+        self.assertEqual(open(TESTFN2).read(), 'HELLO WORLD #2')
+
+    def testSimplePipe3(self):
+        open(TESTFN, 'w').write('hello world #2')
+        t = pipes.Template()
+        t.append('tr a-z A-Z < $IN', pipes.FILEIN_STDOUT)
+        self.assertEqual(t.open(TESTFN, 'r').read(), 'HELLO WORLD #2')
+
+    def testEmptyPipeline1(self):
+        # copy through empty pipe
+        d = 'empty pipeline test COPY'
+        open(TESTFN, 'w').write(d)
+        open(TESTFN2, 'w').write('')
+        t=pipes.Template()
+        t.copy(TESTFN, TESTFN2)
+        self.assertEqual(open(TESTFN2).read(), d)
+
+    def testEmptyPipeline2(self):
+        # read through empty pipe
+        d = 'empty pipeline test READ'
+        open(TESTFN, 'w').write(d)
+        t=pipes.Template()
+        self.assertEqual(t.open(TESTFN, 'r').read(), d)
+
+    def testEmptyPipeline3(self):
+        # write through empty pipe
+        d = 'empty pipeline test WRITE'
+        t = pipes.Template()
+        t.open(TESTFN, 'w').write(d)
+        self.assertEqual(open(TESTFN).read(), d)
+
+    def testQuoting(self):
+        safeunquoted = string.ascii_letters + string.digits + '!@%_-+=:,./'
+        unsafe = '"`$\\'
+
+        self.assertEqual(pipes.quote(safeunquoted), safeunquoted)
+        self.assertEqual(pipes.quote('test file name'), "'test file name'")
+        for u in unsafe:
+            self.assertEqual(pipes.quote('test%sname' % u),
+                              "'test%sname'" % u)
+        for u in unsafe:
+            self.assertEqual(pipes.quote("test%s'name'" % u),
+                              '"test\\%s\'name\'"' % u)
+
+    def testRepr(self):
+        t = pipes.Template()
+        self.assertEqual(repr(t), "<Template instance, steps=[]>")
+        t.append('tr a-z A-Z', pipes.STDIN_STDOUT)
+        self.assertEqual(repr(t),
+                    "<Template instance, steps=[('tr a-z A-Z', '--')]>")
+
+    def testSetDebug(self):
+        t = pipes.Template()
+        t.debug(False)
+        self.assertEqual(t.debugging, False)
+        t.debug(True)
+        self.assertEqual(t.debugging, True)
+
+    def testReadOpenSink(self):
+        # check calling open('r') on a pipe ending with
+        # a sink raises ValueError
+        t = pipes.Template()
+        t.append('boguscmd', pipes.SINK)
+        self.assertRaises(ValueError, t.open, 'bogusfile', 'r')
+
+    def testWriteOpenSource(self):
+        # check calling open('w') on a pipe ending with
+        # a source raises ValueError
+        t = pipes.Template()
+        t.prepend('boguscmd', pipes.SOURCE)
+        self.assertRaises(ValueError, t.open, 'bogusfile', 'w')
+
+    def testBadAppendOptions(self):
+        t = pipes.Template()
+
+        # try a non-string command
+        self.assertRaises(TypeError, t.append, 7, pipes.STDIN_STDOUT)
+
+        # try a type that isn't recognized
+        self.assertRaises(ValueError, t.append, 'boguscmd', 'xx')
+
+        # shouldn't be able to append a source
+        self.assertRaises(ValueError, t.append, 'boguscmd', pipes.SOURCE)
+
+        # check appending two sinks
+        t = pipes.Template()
+        t.append('boguscmd', pipes.SINK)
+        self.assertRaises(ValueError, t.append, 'boguscmd', pipes.SINK)
+
+        # command needing file input but with no $IN
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.append, 'boguscmd $OUT',
+                           pipes.FILEIN_FILEOUT)
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.append, 'boguscmd',
+                           pipes.FILEIN_STDOUT)
+
+        # command needing file output but with no $OUT
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.append, 'boguscmd $IN',
+                           pipes.FILEIN_FILEOUT)
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.append, 'boguscmd',
+                           pipes.STDIN_FILEOUT)
+
+
+    def testBadPrependOptions(self):
+        t = pipes.Template()
+
+        # try a non-string command
+        self.assertRaises(TypeError, t.prepend, 7, pipes.STDIN_STDOUT)
+
+        # try a type that isn't recognized
+        self.assertRaises(ValueError, t.prepend, 'tr a-z A-Z', 'xx')
+
+        # shouldn't be able to prepend a sink
+        self.assertRaises(ValueError, t.prepend, 'boguscmd', pipes.SINK)
+
+        # check prepending two sources
+        t = pipes.Template()
+        t.prepend('boguscmd', pipes.SOURCE)
+        self.assertRaises(ValueError, t.prepend, 'boguscmd', pipes.SOURCE)
+
+        # command needing file input but with no $IN
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.prepend, 'boguscmd $OUT',
+                           pipes.FILEIN_FILEOUT)
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.prepend, 'boguscmd',
+                           pipes.FILEIN_STDOUT)
+
+        # command needing file output but with no $OUT
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.prepend, 'boguscmd $IN',
+                           pipes.FILEIN_FILEOUT)
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.prepend, 'boguscmd',
+                           pipes.STDIN_FILEOUT)
+
+    def testBadOpenMode(self):
+        t = pipes.Template()
+        self.assertRaises(ValueError, t.open, 'bogusfile', 'x')
+
+    def testClone(self):
+        t = pipes.Template()
+        t.append('tr a-z A-Z', pipes.STDIN_STDOUT)
+
+        u = t.clone()
+        self.assertNotEqual(id(t), id(u))
+        self.assertEqual(t.steps, u.steps)
+        self.assertNotEqual(id(t.steps), id(u.steps))
+        self.assertEqual(t.debugging, u.debugging)
+
+def test_main():
+    run_unittest(SimplePipeTests)
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index e1e8055..ad66b69 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -135,8 +135,19 @@
 
 RobotTest(7, doc, good, bad)
 
+class TestCase(unittest.TestCase):
+    def runTest(self):
+        test_support.requires('network')
+        # whole site is password-protected.
+        url = 'http://mueblesmoraleda.com'
+        parser = robotparser.RobotFileParser()
+        parser.set_url(url)
+        parser.read()
+        self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
+
 def test_main():
     test_support.run_unittest(tests)
+    TestCase().run()
 
 if __name__=='__main__':
     test_support.Verbose = 1
diff --git a/Lib/test/test_socket_ssl.py b/Lib/test/test_socket_ssl.py
index fd4383f..6aa451f 100644
--- a/Lib/test/test_socket_ssl.py
+++ b/Lib/test/test_socket_ssl.py
@@ -110,12 +110,12 @@
         if test_support.verbose:
             print("test_978833 ...")
 
-        import os, httplib
+        import os, httplib, ssl
         with test_support.transient_internet():
             s = socket.socket(socket.AF_INET)
             s.connect(("www.sf.net", 443))
             fd = s.fileno()
-            sock = httplib.FakeSocket(s, socket.ssl(s))
+            sock = ssl.sslsocket(s)
             s = None
             sock.close()
             try:
diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
index ed2f14d..d878e7a 100644
--- a/Lib/test/test_sundry.py
+++ b/Lib/test/test_sundry.py
@@ -83,7 +83,6 @@
     import opcode
     import os2emxpath
     import pdb
-    import pipes
     import pstats
     import py_compile
     import pydoc
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
index fc898b8..aaa57c9 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -147,8 +147,7 @@
 
     def testRemoteMachineRegistryWorks(self):
         if not self.remote_name:
-            raise test_support.TestSkipped("Remote machine name "
-                                           "not specified.")
+            return # remote machine name not specified
         remote_key = ConnectRegistry(self.remote_name, HKEY_CURRENT_USER)
         self.TestAll(remote_key)
 
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 07c7ad6..4d496cc 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -441,8 +441,10 @@
             p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
             self.assertEqual(p.pow(6,8), 6**8)
         except xmlrpclib.ProtocolError as e:
-            # protocol error; provide additional information in test output
-            self.fail("%s\n%s" % (e, e.headers))
+            # ignore failures due to non-blocking socket 'unavailable' errors
+            if not is_unavailable_exception(e):
+                # protocol error; provide additional information in test output
+                self.fail("%s\n%s" % (e, e.headers))
 
     def test_fail_no_info(self):
         # use the broken message class
@@ -452,9 +454,11 @@
             p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
             p.pow(6,8)
         except xmlrpclib.ProtocolError as e:
-            # The two server-side error headers shouldn't be sent back in this case
-            self.assertTrue(e.headers.get("X-exception") is None)
-            self.assertTrue(e.headers.get("X-traceback") is None)
+            # ignore failures due to non-blocking socket 'unavailable' errors
+            if not is_unavailable_exception(e):
+                # The two server-side error headers shouldn't be sent back in this case
+                self.assertTrue(e.headers.get("X-exception") is None)
+                self.assertTrue(e.headers.get("X-traceback") is None)
         else:
             self.fail('ProtocolError not raised')
 
@@ -470,10 +474,12 @@
             p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
             p.pow(6,8)
         except xmlrpclib.ProtocolError as e:
-            # We should get error info in the response
-            expected_err = "invalid literal for int() with base 10: 'I am broken'"
-            self.assertEqual(e.headers.get("x-exception"), expected_err)
-            self.assertTrue(e.headers.get("x-traceback") is not None)
+            # ignore failures due to non-blocking socket 'unavailable' errors
+            if not is_unavailable_exception(e):
+                # We should get error info in the response
+                expected_err = "invalid literal for int() with base 10: 'I am broken'"
+                self.assertEqual(e.headers.get("x-exception"), expected_err)
+                self.assertTrue(e.headers.get("x-traceback") is not None)
         else:
             self.fail('ProtocolError not raised')
 
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 3035881..67f457d 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):
@@ -382,7 +390,7 @@
         fp.close()
         raise IOError('http error', errcode, errmsg, headers)
 
-    if hasattr(socket, "ssl"):
+    if _have_ssl:
         def _https_connection(self, host):
             return httplib.HTTPSConnection(host,
                                            key_file=self.key_file,