Merge test suite fixes from 3.6
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 5521e76..d4faeb3 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -630,6 +630,7 @@
         regex = regex.format(ptr=self.PTR_REGEX)
         self.assertRegex(out, regex)
 
+    @unittest.skipUnless(threading, 'Test requires a GIL (multithreading)')
     def check_malloc_without_gil(self, code):
         out = self.check(code)
         expected = ('Fatal Python error: Python memory allocator called '
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index d431604..52909d8 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -696,7 +696,12 @@
         code = TEST_INTERRUPTED
         test = self.create_test("sigint", code=code)
 
-        for multiprocessing in (False, True):
+        try:
+            import threading
+            tests = (False, True)
+        except ImportError:
+            tests = (False,)
+        for multiprocessing in tests:
             if multiprocessing:
                 args = ("--slowest", "-j2", test)
             else:
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 01d0bb9..53ace04 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -4569,6 +4569,7 @@
         sock = socket.socket(
             socket.AF_INET, socket.SOCK_STREAM, 0, sock0.fileno())
         sock0.close()
+        self.addCleanup(sock.detach)
 
         with self.assertRaises(OSError):
             sock.setblocking(False)