Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
number of tests, all because of the codecs/_multibytecodecs issue described
here (it's not a Py3K issue, just something Py3K discovers):
http://mail.python.org/pipermail/python-dev/2006-April/064051.html

Hye-Shik Chang promised to look for a fix, so no need to fix it here. The
tests that are expected to break are:

test_codecencodings_cn
test_codecencodings_hk
test_codecencodings_jp
test_codecencodings_kr
test_codecencodings_tw
test_codecs
test_multibytecodec

This merge fixes an actual test failure (test_weakref) in this branch,
though, so I believe merging is the right thing to do anyway.
diff --git a/Lib/test/check_soundcard.vbs b/Lib/test/check_soundcard.vbs
new file mode 100644
index 0000000..8c21852
--- /dev/null
+++ b/Lib/test/check_soundcard.vbs
@@ -0,0 +1,13 @@
+rem Check for a working sound-card - exit with 0 if OK, 1 otherwise.
+set wmi = GetObject("winmgmts:")
+set scs = wmi.InstancesOf("win32_sounddevice")
+for each sc in scs
+   set status = sc.Properties_("Status")
+   wscript.Echo(sc.Properties_("Name") + "/" + status)
+   if status = "OK" then
+       wscript.Quit 0 rem normal exit
+   end if
+next
+rem No sound card found - exit with status code of 1
+wscript.Quit 1
+
diff --git a/Lib/test/crashers/README b/Lib/test/crashers/README
index 9369282..070c3f1 100644
--- a/Lib/test/crashers/README
+++ b/Lib/test/crashers/README
@@ -13,3 +13,8 @@
 Put as much info into a docstring or comments to help determine
 the cause of the failure.  Particularly note if the cause is
 system or environment dependent and what the variables are.
+
+Once the crash is fixed, the test case should be moved into an appropriate
+test (even if it was originally from the test suite).  This ensures the
+regression doesn't happen again.  And if it does, it should be easier
+to track down.
diff --git a/Lib/test/crashers/dictresize_attack.py b/Lib/test/crashers/dictresize_attack.py
new file mode 100644
index 0000000..1895791
--- /dev/null
+++ b/Lib/test/crashers/dictresize_attack.py
@@ -0,0 +1,32 @@
+# http://www.python.org/sf/1456209
+
+# A dictresize() attack.  If oldtable == mp->ma_smalltable then pure
+# Python code can mangle with mp->ma_smalltable while it is being walked
+# over.
+
+class X(object):
+
+    def __hash__(self):
+        return 5
+
+    def __eq__(self, other):
+        if resizing:
+            d.clear()
+        return False
+
+
+d = {}
+
+resizing = False
+
+d[X()] = 1
+d[X()] = 2
+d[X()] = 3
+d[X()] = 4
+d[X()] = 5
+
+# now trigger a resize
+resizing = True
+d[9] = 6
+
+# ^^^ I get Segmentation fault or Illegal instruction here.
diff --git a/Lib/test/crashers/nasty_eq_vs_dict.py b/Lib/test/crashers/nasty_eq_vs_dict.py
new file mode 100644
index 0000000..3f3083d
--- /dev/null
+++ b/Lib/test/crashers/nasty_eq_vs_dict.py
@@ -0,0 +1,47 @@
+# from http://mail.python.org/pipermail/python-dev/2001-June/015239.html
+
+# if you keep changing a dictionary while looking up a key, you can
+# provoke an infinite recursion in C
+
+# At the time neither Tim nor Michael could be bothered to think of a
+# way to fix it.
+
+class Yuck:
+    def __init__(self):
+        self.i = 0
+
+    def make_dangerous(self):
+        self.i = 1
+
+    def __hash__(self):
+        # direct to slot 4 in table of size 8; slot 12 when size 16
+        return 4 + 8
+
+    def __eq__(self, other):
+        if self.i == 0:
+            # leave dict alone
+            pass
+        elif self.i == 1:
+            # fiddle to 16 slots
+            self.__fill_dict(6)
+            self.i = 2
+        else:
+            # fiddle to 8 slots
+            self.__fill_dict(4)
+            self.i = 1
+
+        return 1
+
+    def __fill_dict(self, n):
+        self.i = 0
+        dict.clear()
+        for i in range(n):
+            dict[i] = i
+        dict[self] = "OK!"
+
+y = Yuck()
+dict = {y: "OK!"}
+
+z = Yuck()
+y.make_dangerous()
+print dict[z]
diff --git a/Lib/test/empty.vbs b/Lib/test/empty.vbs
new file mode 100644
index 0000000..f35f076
--- /dev/null
+++ b/Lib/test/empty.vbs
@@ -0,0 +1 @@
+'Empty VBS file, does nothing.  Helper for Lib\test\test_startfile.py.
\ No newline at end of file
diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py
new file mode 100644
index 0000000..5600bdb
--- /dev/null
+++ b/Lib/test/fork_wait.py
@@ -0,0 +1,71 @@
+"""This test case provides support for checking forking and wait behavior.
+
+To test different wait behavior, overrise the wait_impl method.
+
+We want fork1() semantics -- only the forking thread survives in the
+child after a fork().
+
+On some systems (e.g. Solaris without posix threads) we find that all
+active threads survive in the child after a fork(); this is an error.
+
+While BeOS doesn't officially support fork and native threading in
+the same application, the present example should work just fine.  DC
+"""
+
+import os, sys, time, thread, unittest
+from test.test_support import TestSkipped
+
+LONGSLEEP = 2
+SHORTSLEEP = 0.5
+NUM_THREADS = 4
+
+class ForkWait(unittest.TestCase):
+
+    def setUp(self):
+        self.alive = {}
+        self.stop = 0
+
+    def f(self, id):
+        while not self.stop:
+            self.alive[id] = os.getpid()
+            try:
+                time.sleep(SHORTSLEEP)
+            except IOError:
+                pass
+
+    def wait_impl(self, cpid):
+        spid, status = os.waitpid(cpid, 0)
+        self.assertEquals(spid, cpid)
+        self.assertEquals(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
+
+    def test_wait(self):
+        for i in range(NUM_THREADS):
+            thread.start_new(self.f, (i,))
+
+        time.sleep(LONGSLEEP)
+
+        a = self.alive.keys()
+        a.sort()
+        self.assertEquals(a, range(NUM_THREADS))
+
+        prefork_lives = self.alive.copy()
+
+        if sys.platform in ['unixware7']:
+            cpid = os.fork1()
+        else:
+            cpid = os.fork()
+
+        if cpid == 0:
+            # Child
+            time.sleep(LONGSLEEP)
+            n = 0
+            for key in self.alive:
+                if self.alive[key] != prefork_lives[key]:
+                    n += 1
+            os._exit(n)
+        else:
+            # Parent
+            self.wait_impl(cpid)
+            # Tell threads to die
+            self.stop = 1
+            time.sleep(2*SHORTSLEEP) # Wait for threads to die
diff --git a/Lib/test/leakers/README.txt b/Lib/test/leakers/README.txt
index 69ee35a..beeee0e 100644
--- a/Lib/test/leakers/README.txt
+++ b/Lib/test/leakers/README.txt
@@ -5,6 +5,15 @@
 doesn't increase, the bug has been fixed and the file should be removed
 from the repository.
 
+Note:  be careful to check for cyclic garbage.  Sometimes it may be helpful
+to define the leak function like:
+
+def leak():
+    def inner_leak():
+        # this is the function that leaks, but also creates cycles
+    inner_leak()
+    gc.collect() ; gc.collect() ; gc.collect()
+
 Here's an example interpreter session for test_gestalt which still leaks:
 
 >>> from test.leakers.test_gestalt import leak
@@ -17,3 +26,7 @@
 [28940 refs]
 >>> 
 
+Once the leak is fixed, the test case should be moved into an appropriate
+test (even if it was originally from the test suite).  This ensures the
+regression doesn't happen again.  And if it does, it should be easier
+to track down.
diff --git a/Lib/test/leakers/test_ctypes.py b/Lib/test/leakers/test_ctypes.py
new file mode 100644
index 0000000..0f9a2cd
--- /dev/null
+++ b/Lib/test/leakers/test_ctypes.py
@@ -0,0 +1,16 @@
+
+# Taken from Lib/ctypes/test/test_keeprefs.py, PointerToStructure.test().
+# When this leak is fixed, remember to remove from Misc/build.sh LEAKY_TESTS.
+
+from ctypes import Structure, c_int, POINTER
+import gc
+
+def leak_inner():
+    class POINT(Structure):
+        _fields_ = [("x", c_int)]
+    class RECT(Structure):
+        _fields_ = [("a", POINTER(POINT))]
+
+def leak():
+    leak_inner()
+    gc.collect()
diff --git a/Lib/test/leakers/test_selftype.py b/Lib/test/leakers/test_selftype.py
new file mode 100644
index 0000000..4207c32
--- /dev/null
+++ b/Lib/test/leakers/test_selftype.py
@@ -0,0 +1,13 @@
+# Reference cycles involving only the ob_type field are rather uncommon
+# but possible.  Inspired by SF bug 1469629.
+
+import gc
+
+def leak():
+    class T(type):
+        pass
+    class U(type):
+        __metaclass__ = T
+    U.__class__ = U
+    del U
+    gc.collect(); gc.collect(); gc.collect()
diff --git a/Lib/test/leakers/test_tee.py b/Lib/test/leakers/test_tee.py
deleted file mode 100644
index 4ce24ca..0000000
--- a/Lib/test/leakers/test_tee.py
+++ /dev/null
@@ -1,19 +0,0 @@
-
-# Test case taken from test_itertools
-# See http://mail.python.org/pipermail/python-dev/2005-November/058339.html
-
-from itertools import tee
-
-def leak():
-    def fib():
-        def yield_identity_forever(g):
-            while 1:
-                yield g
-        def _fib():
-            for i in yield_identity_forever(head):
-                yield i
-        head, tail, result = tee(_fib(), 3)
-        return result
-
-    x = fib()
-    x.next()
diff --git a/Lib/test/output/test_augassign b/Lib/test/output/test_augassign
deleted file mode 100644
index b66b7e5..0000000
--- a/Lib/test/output/test_augassign
+++ /dev/null
@@ -1,54 +0,0 @@
-test_augassign
-6.0
-6
-[6.0]
-6
-6.0
-6
-[1, 2, 3, 4, 1, 2, 3, 4]
-[1, 2, 1, 2, 3]
-True
-True
-True
-11
-True
-12
-True
-True
-13
-__add__ called
-__radd__ called
-__iadd__ called
-__sub__ called
-__rsub__ called
-__isub__ called
-__mul__ called
-__rmul__ called
-__imul__ called
-__truediv__ called
-__rtruediv__ called
-__itruediv__ called
-__floordiv__ called
-__rfloordiv__ called
-__ifloordiv__ called
-__mod__ called
-__rmod__ called
-__imod__ called
-__pow__ called
-__rpow__ called
-__ipow__ called
-__or__ called
-__ror__ called
-__ior__ called
-__and__ called
-__rand__ called
-__iand__ called
-__xor__ called
-__rxor__ called
-__ixor__ called
-__rshift__ called
-__rrshift__ called
-__irshift__ called
-__lshift__ called
-__rlshift__ called
-__ilshift__ called
diff --git a/Lib/test/output/test_coercion b/Lib/test/output/test_coercion
deleted file mode 100644
index ad35b60..0000000
--- a/Lib/test/output/test_coercion
+++ /dev/null
@@ -1,1054 +0,0 @@
-test_coercion
-2 + 2 = 4
-2 += 2 => 4
-2 - 2 = 0
-2 -= 2 => 0
-2 * 2 = 4
-2 *= 2 => 4
-2 / 2 = 1
-2 /= 2 => 1
-2 ** 2 = 4
-2 **= 2 => 4
-2 % 2 = 0
-2 %= 2 => 0
-2 + 4.0 = 6.0
-2 += 4.0 => 6.0
-2 - 4.0 = -2.0
-2 -= 4.0 => -2.0
-2 * 4.0 = 8.0
-2 *= 4.0 => 8.0
-2 / 4.0 = 0.5
-2 /= 4.0 => 0.5
-2 ** 4.0 = 16.0
-2 **= 4.0 => 16.0
-2 % 4.0 = 2.0
-2 %= 4.0 => 2.0
-2 + 2 = 4
-2 += 2 => 4
-2 - 2 = 0
-2 -= 2 => 0
-2 * 2 = 4
-2 *= 2 => 4
-2 / 2 = 1
-2 /= 2 => 1
-2 ** 2 = 4
-2 **= 2 => 4
-2 % 2 = 0
-2 %= 2 => 0
-2 + (2+0j) = (4.0 + 0.0j)
-2 += (2+0j) => (4.0 + 0.0j)
-2 - (2+0j) = (0.0 + 0.0j)
-2 -= (2+0j) => (0.0 + 0.0j)
-2 * (2+0j) = (4.0 + 0.0j)
-2 *= (2+0j) => (4.0 + 0.0j)
-2 / (2+0j) = (1.0 + 0.0j)
-2 /= (2+0j) => (1.0 + 0.0j)
-2 ** (2+0j) = (4.0 + 0.0j)
-2 **= (2+0j) => (4.0 + 0.0j)
-2 % (2+0j) = (0.0 + 0.0j)
-2 %= (2+0j) => (0.0 + 0.0j)
-2 + [1] ... exceptions.TypeError
-2 += [1] ... exceptions.TypeError
-2 - [1] ... exceptions.TypeError
-2 -= [1] ... exceptions.TypeError
-2 * [1] = [1, 1]
-2 *= [1] => [1, 1]
-2 / [1] ... exceptions.TypeError
-2 /= [1] ... exceptions.TypeError
-2 ** [1] ... exceptions.TypeError
-2 **= [1] ... exceptions.TypeError
-2 % [1] ... exceptions.TypeError
-2 %= [1] ... exceptions.TypeError
-2 + (2,) ... exceptions.TypeError
-2 += (2,) ... exceptions.TypeError
-2 - (2,) ... exceptions.TypeError
-2 -= (2,) ... exceptions.TypeError
-2 * (2,) = (2, 2)
-2 *= (2,) => (2, 2)
-2 / (2,) ... exceptions.TypeError
-2 /= (2,) ... exceptions.TypeError
-2 ** (2,) ... exceptions.TypeError
-2 **= (2,) ... exceptions.TypeError
-2 % (2,) ... exceptions.TypeError
-2 %= (2,) ... exceptions.TypeError
-2 + None ... exceptions.TypeError
-2 += None ... exceptions.TypeError
-2 - None ... exceptions.TypeError
-2 -= None ... exceptions.TypeError
-2 * None ... exceptions.TypeError
-2 *= None ... exceptions.TypeError
-2 / None ... exceptions.TypeError
-2 /= None ... exceptions.TypeError
-2 ** None ... exceptions.TypeError
-2 **= None ... exceptions.TypeError
-2 % None ... exceptions.TypeError
-2 %= None ... exceptions.TypeError
-2 + <MethodNumber 2> = 4
-2 += <MethodNumber 2> => 4
-2 - <MethodNumber 2> = 0
-2 -= <MethodNumber 2> => 0
-2 * <MethodNumber 2> = 4
-2 *= <MethodNumber 2> => 4
-2 / <MethodNumber 2> = 1
-2 /= <MethodNumber 2> => 1
-2 ** <MethodNumber 2> = 4
-2 **= <MethodNumber 2> => 4
-2 % <MethodNumber 2> = 0
-2 %= <MethodNumber 2> => 0
-2 + <CoerceNumber 2> = 4
-2 += <CoerceNumber 2> => 4
-2 - <CoerceNumber 2> = 0
-2 -= <CoerceNumber 2> => 0
-2 * <CoerceNumber 2> = 4
-2 *= <CoerceNumber 2> => 4
-2 / <CoerceNumber 2> = 1
-2 /= <CoerceNumber 2> => 1
-2 ** <CoerceNumber 2> = 4
-2 **= <CoerceNumber 2> => 4
-2 % <CoerceNumber 2> = 0
-2 %= <CoerceNumber 2> => 0
-4.0 + 2 = 6.0
-4.0 += 2 => 6.0
-4.0 - 2 = 2.0
-4.0 -= 2 => 2.0
-4.0 * 2 = 8.0
-4.0 *= 2 => 8.0
-4.0 / 2 = 2.0
-4.0 /= 2 => 2.0
-4.0 ** 2 = 16.0
-4.0 **= 2 => 16.0
-4.0 % 2 = 0.0
-4.0 %= 2 => 0.0
-4.0 + 4.0 = 8.0
-4.0 += 4.0 => 8.0
-4.0 - 4.0 = 0.0
-4.0 -= 4.0 => 0.0
-4.0 * 4.0 = 16.0
-4.0 *= 4.0 => 16.0
-4.0 / 4.0 = 1.0
-4.0 /= 4.0 => 1.0
-4.0 ** 4.0 = 256.0
-4.0 **= 4.0 => 256.0
-4.0 % 4.0 = 0.0
-4.0 %= 4.0 => 0.0
-4.0 + 2 = 6.0
-4.0 += 2 => 6.0
-4.0 - 2 = 2.0
-4.0 -= 2 => 2.0
-4.0 * 2 = 8.0
-4.0 *= 2 => 8.0
-4.0 / 2 = 2.0
-4.0 /= 2 => 2.0
-4.0 ** 2 = 16.0
-4.0 **= 2 => 16.0
-4.0 % 2 = 0.0
-4.0 %= 2 => 0.0
-4.0 + (2+0j) = (6.0 + 0.0j)
-4.0 += (2+0j) => (6.0 + 0.0j)
-4.0 - (2+0j) = (2.0 + 0.0j)
-4.0 -= (2+0j) => (2.0 + 0.0j)
-4.0 * (2+0j) = (8.0 + 0.0j)
-4.0 *= (2+0j) => (8.0 + 0.0j)
-4.0 / (2+0j) = (2.0 + 0.0j)
-4.0 /= (2+0j) => (2.0 + 0.0j)
-4.0 ** (2+0j) = (16.0 + 0.0j)
-4.0 **= (2+0j) => (16.0 + 0.0j)
-4.0 % (2+0j) = (0.0 + 0.0j)
-4.0 %= (2+0j) => (0.0 + 0.0j)
-4.0 + [1] ... exceptions.TypeError
-4.0 += [1] ... exceptions.TypeError
-4.0 - [1] ... exceptions.TypeError
-4.0 -= [1] ... exceptions.TypeError
-4.0 * [1] ... exceptions.TypeError
-4.0 *= [1] ... exceptions.TypeError
-4.0 / [1] ... exceptions.TypeError
-4.0 /= [1] ... exceptions.TypeError
-4.0 ** [1] ... exceptions.TypeError
-4.0 **= [1] ... exceptions.TypeError
-4.0 % [1] ... exceptions.TypeError
-4.0 %= [1] ... exceptions.TypeError
-4.0 + (2,) ... exceptions.TypeError
-4.0 += (2,) ... exceptions.TypeError
-4.0 - (2,) ... exceptions.TypeError
-4.0 -= (2,) ... exceptions.TypeError
-4.0 * (2,) ... exceptions.TypeError
-4.0 *= (2,) ... exceptions.TypeError
-4.0 / (2,) ... exceptions.TypeError
-4.0 /= (2,) ... exceptions.TypeError
-4.0 ** (2,) ... exceptions.TypeError
-4.0 **= (2,) ... exceptions.TypeError
-4.0 % (2,) ... exceptions.TypeError
-4.0 %= (2,) ... exceptions.TypeError
-4.0 + None ... exceptions.TypeError
-4.0 += None ... exceptions.TypeError
-4.0 - None ... exceptions.TypeError
-4.0 -= None ... exceptions.TypeError
-4.0 * None ... exceptions.TypeError
-4.0 *= None ... exceptions.TypeError
-4.0 / None ... exceptions.TypeError
-4.0 /= None ... exceptions.TypeError
-4.0 ** None ... exceptions.TypeError
-4.0 **= None ... exceptions.TypeError
-4.0 % None ... exceptions.TypeError
-4.0 %= None ... exceptions.TypeError
-4.0 + <MethodNumber 2> = 6.0
-4.0 += <MethodNumber 2> => 6.0
-4.0 - <MethodNumber 2> = 2.0
-4.0 -= <MethodNumber 2> => 2.0
-4.0 * <MethodNumber 2> = 8.0
-4.0 *= <MethodNumber 2> => 8.0
-4.0 / <MethodNumber 2> = 2.0
-4.0 /= <MethodNumber 2> => 2.0
-4.0 ** <MethodNumber 2> = 16.0
-4.0 **= <MethodNumber 2> => 16.0
-4.0 % <MethodNumber 2> = 0.0
-4.0 %= <MethodNumber 2> => 0.0
-4.0 + <CoerceNumber 2> = 6.0
-4.0 += <CoerceNumber 2> => 6.0
-4.0 - <CoerceNumber 2> = 2.0
-4.0 -= <CoerceNumber 2> => 2.0
-4.0 * <CoerceNumber 2> = 8.0
-4.0 *= <CoerceNumber 2> => 8.0
-4.0 / <CoerceNumber 2> = 2.0
-4.0 /= <CoerceNumber 2> => 2.0
-4.0 ** <CoerceNumber 2> = 16.0
-4.0 **= <CoerceNumber 2> => 16.0
-4.0 % <CoerceNumber 2> = 0.0
-4.0 %= <CoerceNumber 2> => 0.0
-2 + 2 = 4
-2 += 2 => 4
-2 - 2 = 0
-2 -= 2 => 0
-2 * 2 = 4
-2 *= 2 => 4
-2 / 2 = 1
-2 /= 2 => 1
-2 ** 2 = 4
-2 **= 2 => 4
-2 % 2 = 0
-2 %= 2 => 0
-2 + 4.0 = 6.0
-2 += 4.0 => 6.0
-2 - 4.0 = -2.0
-2 -= 4.0 => -2.0
-2 * 4.0 = 8.0
-2 *= 4.0 => 8.0
-2 / 4.0 = 0.5
-2 /= 4.0 => 0.5
-2 ** 4.0 = 16.0
-2 **= 4.0 => 16.0
-2 % 4.0 = 2.0
-2 %= 4.0 => 2.0
-2 + 2 = 4
-2 += 2 => 4
-2 - 2 = 0
-2 -= 2 => 0
-2 * 2 = 4
-2 *= 2 => 4
-2 / 2 = 1
-2 /= 2 => 1
-2 ** 2 = 4
-2 **= 2 => 4
-2 % 2 = 0
-2 %= 2 => 0
-2 + (2+0j) = (4.0 + 0.0j)
-2 += (2+0j) => (4.0 + 0.0j)
-2 - (2+0j) = (0.0 + 0.0j)
-2 -= (2+0j) => (0.0 + 0.0j)
-2 * (2+0j) = (4.0 + 0.0j)
-2 *= (2+0j) => (4.0 + 0.0j)
-2 / (2+0j) = (1.0 + 0.0j)
-2 /= (2+0j) => (1.0 + 0.0j)
-2 ** (2+0j) = (4.0 + 0.0j)
-2 **= (2+0j) => (4.0 + 0.0j)
-2 % (2+0j) = (0.0 + 0.0j)
-2 %= (2+0j) => (0.0 + 0.0j)
-2 + [1] ... exceptions.TypeError
-2 += [1] ... exceptions.TypeError
-2 - [1] ... exceptions.TypeError
-2 -= [1] ... exceptions.TypeError
-2 * [1] = [1, 1]
-2 *= [1] => [1, 1]
-2 / [1] ... exceptions.TypeError
-2 /= [1] ... exceptions.TypeError
-2 ** [1] ... exceptions.TypeError
-2 **= [1] ... exceptions.TypeError
-2 % [1] ... exceptions.TypeError
-2 %= [1] ... exceptions.TypeError
-2 + (2,) ... exceptions.TypeError
-2 += (2,) ... exceptions.TypeError
-2 - (2,) ... exceptions.TypeError
-2 -= (2,) ... exceptions.TypeError
-2 * (2,) = (2, 2)
-2 *= (2,) => (2, 2)
-2 / (2,) ... exceptions.TypeError
-2 /= (2,) ... exceptions.TypeError
-2 ** (2,) ... exceptions.TypeError
-2 **= (2,) ... exceptions.TypeError
-2 % (2,) ... exceptions.TypeError
-2 %= (2,) ... exceptions.TypeError
-2 + None ... exceptions.TypeError
-2 += None ... exceptions.TypeError
-2 - None ... exceptions.TypeError
-2 -= None ... exceptions.TypeError
-2 * None ... exceptions.TypeError
-2 *= None ... exceptions.TypeError
-2 / None ... exceptions.TypeError
-2 /= None ... exceptions.TypeError
-2 ** None ... exceptions.TypeError
-2 **= None ... exceptions.TypeError
-2 % None ... exceptions.TypeError
-2 %= None ... exceptions.TypeError
-2 + <MethodNumber 2> = 4
-2 += <MethodNumber 2> => 4
-2 - <MethodNumber 2> = 0
-2 -= <MethodNumber 2> => 0
-2 * <MethodNumber 2> = 4
-2 *= <MethodNumber 2> => 4
-2 / <MethodNumber 2> = 1
-2 /= <MethodNumber 2> => 1
-2 ** <MethodNumber 2> = 4
-2 **= <MethodNumber 2> => 4
-2 % <MethodNumber 2> = 0
-2 %= <MethodNumber 2> => 0
-2 + <CoerceNumber 2> = 4
-2 += <CoerceNumber 2> => 4
-2 - <CoerceNumber 2> = 0
-2 -= <CoerceNumber 2> => 0
-2 * <CoerceNumber 2> = 4
-2 *= <CoerceNumber 2> => 4
-2 / <CoerceNumber 2> = 1
-2 /= <CoerceNumber 2> => 1
-2 ** <CoerceNumber 2> = 4
-2 **= <CoerceNumber 2> => 4
-2 % <CoerceNumber 2> = 0
-2 %= <CoerceNumber 2> => 0
-(2+0j) + 2 = (4.0 + 0.0j)
-(2+0j) += 2 => (4.0 + 0.0j)
-(2+0j) - 2 = (0.0 + 0.0j)
-(2+0j) -= 2 => (0.0 + 0.0j)
-(2+0j) * 2 = (4.0 + 0.0j)
-(2+0j) *= 2 => (4.0 + 0.0j)
-(2+0j) / 2 = (1.0 + 0.0j)
-(2+0j) /= 2 => (1.0 + 0.0j)
-(2+0j) ** 2 = (4.0 + 0.0j)
-(2+0j) **= 2 => (4.0 + 0.0j)
-(2+0j) % 2 = (0.0 + 0.0j)
-(2+0j) %= 2 => (0.0 + 0.0j)
-(2+0j) + 4.0 = (6.0 + 0.0j)
-(2+0j) += 4.0 => (6.0 + 0.0j)
-(2+0j) - 4.0 = (-2.0 + 0.0j)
-(2+0j) -= 4.0 => (-2.0 + 0.0j)
-(2+0j) * 4.0 = (8.0 + 0.0j)
-(2+0j) *= 4.0 => (8.0 + 0.0j)
-(2+0j) / 4.0 = (0.5 + 0.0j)
-(2+0j) /= 4.0 => (0.5 + 0.0j)
-(2+0j) ** 4.0 = (16.0 + 0.0j)
-(2+0j) **= 4.0 => (16.0 + 0.0j)
-(2+0j) % 4.0 = (2.0 + 0.0j)
-(2+0j) %= 4.0 => (2.0 + 0.0j)
-(2+0j) + 2 = (4.0 + 0.0j)
-(2+0j) += 2 => (4.0 + 0.0j)
-(2+0j) - 2 = (0.0 + 0.0j)
-(2+0j) -= 2 => (0.0 + 0.0j)
-(2+0j) * 2 = (4.0 + 0.0j)
-(2+0j) *= 2 => (4.0 + 0.0j)
-(2+0j) / 2 = (1.0 + 0.0j)
-(2+0j) /= 2 => (1.0 + 0.0j)
-(2+0j) ** 2 = (4.0 + 0.0j)
-(2+0j) **= 2 => (4.0 + 0.0j)
-(2+0j) % 2 = (0.0 + 0.0j)
-(2+0j) %= 2 => (0.0 + 0.0j)
-(2+0j) + (2+0j) = (4.0 + 0.0j)
-(2+0j) += (2+0j) => (4.0 + 0.0j)
-(2+0j) - (2+0j) = (0.0 + 0.0j)
-(2+0j) -= (2+0j) => (0.0 + 0.0j)
-(2+0j) * (2+0j) = (4.0 + 0.0j)
-(2+0j) *= (2+0j) => (4.0 + 0.0j)
-(2+0j) / (2+0j) = (1.0 + 0.0j)
-(2+0j) /= (2+0j) => (1.0 + 0.0j)
-(2+0j) ** (2+0j) = (4.0 + 0.0j)
-(2+0j) **= (2+0j) => (4.0 + 0.0j)
-(2+0j) % (2+0j) = (0.0 + 0.0j)
-(2+0j) %= (2+0j) => (0.0 + 0.0j)
-(2+0j) + [1] ... exceptions.TypeError
-(2+0j) += [1] ... exceptions.TypeError
-(2+0j) - [1] ... exceptions.TypeError
-(2+0j) -= [1] ... exceptions.TypeError
-(2+0j) * [1] ... exceptions.TypeError
-(2+0j) *= [1] ... exceptions.TypeError
-(2+0j) / [1] ... exceptions.TypeError
-(2+0j) /= [1] ... exceptions.TypeError
-(2+0j) ** [1] ... exceptions.TypeError
-(2+0j) **= [1] ... exceptions.TypeError
-(2+0j) % [1] ... exceptions.TypeError
-(2+0j) %= [1] ... exceptions.TypeError
-(2+0j) + (2,) ... exceptions.TypeError
-(2+0j) += (2,) ... exceptions.TypeError
-(2+0j) - (2,) ... exceptions.TypeError
-(2+0j) -= (2,) ... exceptions.TypeError
-(2+0j) * (2,) ... exceptions.TypeError
-(2+0j) *= (2,) ... exceptions.TypeError
-(2+0j) / (2,) ... exceptions.TypeError
-(2+0j) /= (2,) ... exceptions.TypeError
-(2+0j) ** (2,) ... exceptions.TypeError
-(2+0j) **= (2,) ... exceptions.TypeError
-(2+0j) % (2,) ... exceptions.TypeError
-(2+0j) %= (2,) ... exceptions.TypeError
-(2+0j) + None ... exceptions.TypeError
-(2+0j) += None ... exceptions.TypeError
-(2+0j) - None ... exceptions.TypeError
-(2+0j) -= None ... exceptions.TypeError
-(2+0j) * None ... exceptions.TypeError
-(2+0j) *= None ... exceptions.TypeError
-(2+0j) / None ... exceptions.TypeError
-(2+0j) /= None ... exceptions.TypeError
-(2+0j) ** None ... exceptions.TypeError
-(2+0j) **= None ... exceptions.TypeError
-(2+0j) % None ... exceptions.TypeError
-(2+0j) %= None ... exceptions.TypeError
-(2+0j) + <MethodNumber 2> = (4.0 + 0.0j)
-(2+0j) += <MethodNumber 2> => (4.0 + 0.0j)
-(2+0j) - <MethodNumber 2> = (0.0 + 0.0j)
-(2+0j) -= <MethodNumber 2> => (0.0 + 0.0j)
-(2+0j) * <MethodNumber 2> = (4.0 + 0.0j)
-(2+0j) *= <MethodNumber 2> => (4.0 + 0.0j)
-(2+0j) / <MethodNumber 2> = (1.0 + 0.0j)
-(2+0j) /= <MethodNumber 2> => (1.0 + 0.0j)
-(2+0j) ** <MethodNumber 2> = (4.0 + 0.0j)
-(2+0j) **= <MethodNumber 2> => (4.0 + 0.0j)
-(2+0j) % <MethodNumber 2> = (0.0 + 0.0j)
-(2+0j) %= <MethodNumber 2> => (0.0 + 0.0j)
-(2+0j) + <CoerceNumber 2> = (4.0 + 0.0j)
-(2+0j) += <CoerceNumber 2> => (4.0 + 0.0j)
-(2+0j) - <CoerceNumber 2> = (0.0 + 0.0j)
-(2+0j) -= <CoerceNumber 2> => (0.0 + 0.0j)
-(2+0j) * <CoerceNumber 2> = (4.0 + 0.0j)
-(2+0j) *= <CoerceNumber 2> => (4.0 + 0.0j)
-(2+0j) / <CoerceNumber 2> = (1.0 + 0.0j)
-(2+0j) /= <CoerceNumber 2> => (1.0 + 0.0j)
-(2+0j) ** <CoerceNumber 2> = (4.0 + 0.0j)
-(2+0j) **= <CoerceNumber 2> => (4.0 + 0.0j)
-(2+0j) % <CoerceNumber 2> = (0.0 + 0.0j)
-(2+0j) %= <CoerceNumber 2> => (0.0 + 0.0j)
-[1] + 2 ... exceptions.TypeError
-[1] += 2 ... exceptions.TypeError
-[1] - 2 ... exceptions.TypeError
-[1] -= 2 ... exceptions.TypeError
-[1] * 2 = [1, 1]
-[1] *= 2 => [1, 1]
-[1] / 2 ... exceptions.TypeError
-[1] /= 2 ... exceptions.TypeError
-[1] ** 2 ... exceptions.TypeError
-[1] **= 2 ... exceptions.TypeError
-[1] % 2 ... exceptions.TypeError
-[1] %= 2 ... exceptions.TypeError
-[1] + 4.0 ... exceptions.TypeError
-[1] += 4.0 ... exceptions.TypeError
-[1] - 4.0 ... exceptions.TypeError
-[1] -= 4.0 ... exceptions.TypeError
-[1] * 4.0 ... exceptions.TypeError
-[1] *= 4.0 ... exceptions.TypeError
-[1] / 4.0 ... exceptions.TypeError
-[1] /= 4.0 ... exceptions.TypeError
-[1] ** 4.0 ... exceptions.TypeError
-[1] **= 4.0 ... exceptions.TypeError
-[1] % 4.0 ... exceptions.TypeError
-[1] %= 4.0 ... exceptions.TypeError
-[1] + 2 ... exceptions.TypeError
-[1] += 2 ... exceptions.TypeError
-[1] - 2 ... exceptions.TypeError
-[1] -= 2 ... exceptions.TypeError
-[1] * 2 = [1, 1]
-[1] *= 2 => [1, 1]
-[1] / 2 ... exceptions.TypeError
-[1] /= 2 ... exceptions.TypeError
-[1] ** 2 ... exceptions.TypeError
-[1] **= 2 ... exceptions.TypeError
-[1] % 2 ... exceptions.TypeError
-[1] %= 2 ... exceptions.TypeError
-[1] + (2+0j) ... exceptions.TypeError
-[1] += (2+0j) ... exceptions.TypeError
-[1] - (2+0j) ... exceptions.TypeError
-[1] -= (2+0j) ... exceptions.TypeError
-[1] * (2+0j) ... exceptions.TypeError
-[1] *= (2+0j) ... exceptions.TypeError
-[1] / (2+0j) ... exceptions.TypeError
-[1] /= (2+0j) ... exceptions.TypeError
-[1] ** (2+0j) ... exceptions.TypeError
-[1] **= (2+0j) ... exceptions.TypeError
-[1] % (2+0j) ... exceptions.TypeError
-[1] %= (2+0j) ... exceptions.TypeError
-[1] + [1] = [1, 1]
-[1] += [1] => [1, 1]
-[1] - [1] ... exceptions.TypeError
-[1] -= [1] ... exceptions.TypeError
-[1] * [1] ... exceptions.TypeError
-[1] *= [1] ... exceptions.TypeError
-[1] / [1] ... exceptions.TypeError
-[1] /= [1] ... exceptions.TypeError
-[1] ** [1] ... exceptions.TypeError
-[1] **= [1] ... exceptions.TypeError
-[1] % [1] ... exceptions.TypeError
-[1] %= [1] ... exceptions.TypeError
-[1] + (2,) ... exceptions.TypeError
-[1] += (2,) => [1, 2]
-[1] - (2,) ... exceptions.TypeError
-[1] -= (2,) ... exceptions.TypeError
-[1] * (2,) ... exceptions.TypeError
-[1] *= (2,) ... exceptions.TypeError
-[1] / (2,) ... exceptions.TypeError
-[1] /= (2,) ... exceptions.TypeError
-[1] ** (2,) ... exceptions.TypeError
-[1] **= (2,) ... exceptions.TypeError
-[1] % (2,) ... exceptions.TypeError
-[1] %= (2,) ... exceptions.TypeError
-[1] + None ... exceptions.TypeError
-[1] += None ... exceptions.TypeError
-[1] - None ... exceptions.TypeError
-[1] -= None ... exceptions.TypeError
-[1] * None ... exceptions.TypeError
-[1] *= None ... exceptions.TypeError
-[1] / None ... exceptions.TypeError
-[1] /= None ... exceptions.TypeError
-[1] ** None ... exceptions.TypeError
-[1] **= None ... exceptions.TypeError
-[1] % None ... exceptions.TypeError
-[1] %= None ... exceptions.TypeError
-[1] + <MethodNumber 2> ... exceptions.TypeError
-[1] += <MethodNumber 2> ... exceptions.TypeError
-[1] - <MethodNumber 2> ... exceptions.TypeError
-[1] -= <MethodNumber 2> ... exceptions.TypeError
-[1] * <MethodNumber 2> = [1, 1]
-[1] *= <MethodNumber 2> => [1, 1]
-[1] / <MethodNumber 2> ... exceptions.TypeError
-[1] /= <MethodNumber 2> ... exceptions.TypeError
-[1] ** <MethodNumber 2> ... exceptions.TypeError
-[1] **= <MethodNumber 2> ... exceptions.TypeError
-[1] % <MethodNumber 2> ... exceptions.TypeError
-[1] %= <MethodNumber 2> ... exceptions.TypeError
-[1] + <CoerceNumber 2> ... exceptions.TypeError
-[1] += <CoerceNumber 2> ... exceptions.TypeError
-[1] - <CoerceNumber 2> ... exceptions.TypeError
-[1] -= <CoerceNumber 2> ... exceptions.TypeError
-[1] * <CoerceNumber 2> = [1, 1]
-[1] *= <CoerceNumber 2> => [1, 1]
-[1] / <CoerceNumber 2> ... exceptions.TypeError
-[1] /= <CoerceNumber 2> ... exceptions.TypeError
-[1] ** <CoerceNumber 2> ... exceptions.TypeError
-[1] **= <CoerceNumber 2> ... exceptions.TypeError
-[1] % <CoerceNumber 2> ... exceptions.TypeError
-[1] %= <CoerceNumber 2> ... exceptions.TypeError
-(2,) + 2 ... exceptions.TypeError
-(2,) += 2 ... exceptions.TypeError
-(2,) - 2 ... exceptions.TypeError
-(2,) -= 2 ... exceptions.TypeError
-(2,) * 2 = (2, 2)
-(2,) *= 2 => (2, 2)
-(2,) / 2 ... exceptions.TypeError
-(2,) /= 2 ... exceptions.TypeError
-(2,) ** 2 ... exceptions.TypeError
-(2,) **= 2 ... exceptions.TypeError
-(2,) % 2 ... exceptions.TypeError
-(2,) %= 2 ... exceptions.TypeError
-(2,) + 4.0 ... exceptions.TypeError
-(2,) += 4.0 ... exceptions.TypeError
-(2,) - 4.0 ... exceptions.TypeError
-(2,) -= 4.0 ... exceptions.TypeError
-(2,) * 4.0 ... exceptions.TypeError
-(2,) *= 4.0 ... exceptions.TypeError
-(2,) / 4.0 ... exceptions.TypeError
-(2,) /= 4.0 ... exceptions.TypeError
-(2,) ** 4.0 ... exceptions.TypeError
-(2,) **= 4.0 ... exceptions.TypeError
-(2,) % 4.0 ... exceptions.TypeError
-(2,) %= 4.0 ... exceptions.TypeError
-(2,) + 2 ... exceptions.TypeError
-(2,) += 2 ... exceptions.TypeError
-(2,) - 2 ... exceptions.TypeError
-(2,) -= 2 ... exceptions.TypeError
-(2,) * 2 = (2, 2)
-(2,) *= 2 => (2, 2)
-(2,) / 2 ... exceptions.TypeError
-(2,) /= 2 ... exceptions.TypeError
-(2,) ** 2 ... exceptions.TypeError
-(2,) **= 2 ... exceptions.TypeError
-(2,) % 2 ... exceptions.TypeError
-(2,) %= 2 ... exceptions.TypeError
-(2,) + (2+0j) ... exceptions.TypeError
-(2,) += (2+0j) ... exceptions.TypeError
-(2,) - (2+0j) ... exceptions.TypeError
-(2,) -= (2+0j) ... exceptions.TypeError
-(2,) * (2+0j) ... exceptions.TypeError
-(2,) *= (2+0j) ... exceptions.TypeError
-(2,) / (2+0j) ... exceptions.TypeError
-(2,) /= (2+0j) ... exceptions.TypeError
-(2,) ** (2+0j) ... exceptions.TypeError
-(2,) **= (2+0j) ... exceptions.TypeError
-(2,) % (2+0j) ... exceptions.TypeError
-(2,) %= (2+0j) ... exceptions.TypeError
-(2,) + [1] ... exceptions.TypeError
-(2,) += [1] ... exceptions.TypeError
-(2,) - [1] ... exceptions.TypeError
-(2,) -= [1] ... exceptions.TypeError
-(2,) * [1] ... exceptions.TypeError
-(2,) *= [1] ... exceptions.TypeError
-(2,) / [1] ... exceptions.TypeError
-(2,) /= [1] ... exceptions.TypeError
-(2,) ** [1] ... exceptions.TypeError
-(2,) **= [1] ... exceptions.TypeError
-(2,) % [1] ... exceptions.TypeError
-(2,) %= [1] ... exceptions.TypeError
-(2,) + (2,) = (2, 2)
-(2,) += (2,) => (2, 2)
-(2,) - (2,) ... exceptions.TypeError
-(2,) -= (2,) ... exceptions.TypeError
-(2,) * (2,) ... exceptions.TypeError
-(2,) *= (2,) ... exceptions.TypeError
-(2,) / (2,) ... exceptions.TypeError
-(2,) /= (2,) ... exceptions.TypeError
-(2,) ** (2,) ... exceptions.TypeError
-(2,) **= (2,) ... exceptions.TypeError
-(2,) % (2,) ... exceptions.TypeError
-(2,) %= (2,) ... exceptions.TypeError
-(2,) + None ... exceptions.TypeError
-(2,) += None ... exceptions.TypeError
-(2,) - None ... exceptions.TypeError
-(2,) -= None ... exceptions.TypeError
-(2,) * None ... exceptions.TypeError
-(2,) *= None ... exceptions.TypeError
-(2,) / None ... exceptions.TypeError
-(2,) /= None ... exceptions.TypeError
-(2,) ** None ... exceptions.TypeError
-(2,) **= None ... exceptions.TypeError
-(2,) % None ... exceptions.TypeError
-(2,) %= None ... exceptions.TypeError
-(2,) + <MethodNumber 2> ... exceptions.TypeError
-(2,) += <MethodNumber 2> ... exceptions.TypeError
-(2,) - <MethodNumber 2> ... exceptions.TypeError
-(2,) -= <MethodNumber 2> ... exceptions.TypeError
-(2,) * <MethodNumber 2> = (2, 2)
-(2,) *= <MethodNumber 2> => (2, 2)
-(2,) / <MethodNumber 2> ... exceptions.TypeError
-(2,) /= <MethodNumber 2> ... exceptions.TypeError
-(2,) ** <MethodNumber 2> ... exceptions.TypeError
-(2,) **= <MethodNumber 2> ... exceptions.TypeError
-(2,) % <MethodNumber 2> ... exceptions.TypeError
-(2,) %= <MethodNumber 2> ... exceptions.TypeError
-(2,) + <CoerceNumber 2> ... exceptions.TypeError
-(2,) += <CoerceNumber 2> ... exceptions.TypeError
-(2,) - <CoerceNumber 2> ... exceptions.TypeError
-(2,) -= <CoerceNumber 2> ... exceptions.TypeError
-(2,) * <CoerceNumber 2> = (2, 2)
-(2,) *= <CoerceNumber 2> => (2, 2)
-(2,) / <CoerceNumber 2> ... exceptions.TypeError
-(2,) /= <CoerceNumber 2> ... exceptions.TypeError
-(2,) ** <CoerceNumber 2> ... exceptions.TypeError
-(2,) **= <CoerceNumber 2> ... exceptions.TypeError
-(2,) % <CoerceNumber 2> ... exceptions.TypeError
-(2,) %= <CoerceNumber 2> ... exceptions.TypeError
-None + 2 ... exceptions.TypeError
-None += 2 ... exceptions.TypeError
-None - 2 ... exceptions.TypeError
-None -= 2 ... exceptions.TypeError
-None * 2 ... exceptions.TypeError
-None *= 2 ... exceptions.TypeError
-None / 2 ... exceptions.TypeError
-None /= 2 ... exceptions.TypeError
-None ** 2 ... exceptions.TypeError
-None **= 2 ... exceptions.TypeError
-None % 2 ... exceptions.TypeError
-None %= 2 ... exceptions.TypeError
-None + 4.0 ... exceptions.TypeError
-None += 4.0 ... exceptions.TypeError
-None - 4.0 ... exceptions.TypeError
-None -= 4.0 ... exceptions.TypeError
-None * 4.0 ... exceptions.TypeError
-None *= 4.0 ... exceptions.TypeError
-None / 4.0 ... exceptions.TypeError
-None /= 4.0 ... exceptions.TypeError
-None ** 4.0 ... exceptions.TypeError
-None **= 4.0 ... exceptions.TypeError
-None % 4.0 ... exceptions.TypeError
-None %= 4.0 ... exceptions.TypeError
-None + 2 ... exceptions.TypeError
-None += 2 ... exceptions.TypeError
-None - 2 ... exceptions.TypeError
-None -= 2 ... exceptions.TypeError
-None * 2 ... exceptions.TypeError
-None *= 2 ... exceptions.TypeError
-None / 2 ... exceptions.TypeError
-None /= 2 ... exceptions.TypeError
-None ** 2 ... exceptions.TypeError
-None **= 2 ... exceptions.TypeError
-None % 2 ... exceptions.TypeError
-None %= 2 ... exceptions.TypeError
-None + (2+0j) ... exceptions.TypeError
-None += (2+0j) ... exceptions.TypeError
-None - (2+0j) ... exceptions.TypeError
-None -= (2+0j) ... exceptions.TypeError
-None * (2+0j) ... exceptions.TypeError
-None *= (2+0j) ... exceptions.TypeError
-None / (2+0j) ... exceptions.TypeError
-None /= (2+0j) ... exceptions.TypeError
-None ** (2+0j) ... exceptions.TypeError
-None **= (2+0j) ... exceptions.TypeError
-None % (2+0j) ... exceptions.TypeError
-None %= (2+0j) ... exceptions.TypeError
-None + [1] ... exceptions.TypeError
-None += [1] ... exceptions.TypeError
-None - [1] ... exceptions.TypeError
-None -= [1] ... exceptions.TypeError
-None * [1] ... exceptions.TypeError
-None *= [1] ... exceptions.TypeError
-None / [1] ... exceptions.TypeError
-None /= [1] ... exceptions.TypeError
-None ** [1] ... exceptions.TypeError
-None **= [1] ... exceptions.TypeError
-None % [1] ... exceptions.TypeError
-None %= [1] ... exceptions.TypeError
-None + (2,) ... exceptions.TypeError
-None += (2,) ... exceptions.TypeError
-None - (2,) ... exceptions.TypeError
-None -= (2,) ... exceptions.TypeError
-None * (2,) ... exceptions.TypeError
-None *= (2,) ... exceptions.TypeError
-None / (2,) ... exceptions.TypeError
-None /= (2,) ... exceptions.TypeError
-None ** (2,) ... exceptions.TypeError
-None **= (2,) ... exceptions.TypeError
-None % (2,) ... exceptions.TypeError
-None %= (2,) ... exceptions.TypeError
-None + None ... exceptions.TypeError
-None += None ... exceptions.TypeError
-None - None ... exceptions.TypeError
-None -= None ... exceptions.TypeError
-None * None ... exceptions.TypeError
-None *= None ... exceptions.TypeError
-None / None ... exceptions.TypeError
-None /= None ... exceptions.TypeError
-None ** None ... exceptions.TypeError
-None **= None ... exceptions.TypeError
-None % None ... exceptions.TypeError
-None %= None ... exceptions.TypeError
-None + <MethodNumber 2> ... exceptions.TypeError
-None += <MethodNumber 2> ... exceptions.TypeError
-None - <MethodNumber 2> ... exceptions.TypeError
-None -= <MethodNumber 2> ... exceptions.TypeError
-None * <MethodNumber 2> ... exceptions.TypeError
-None *= <MethodNumber 2> ... exceptions.TypeError
-None / <MethodNumber 2> ... exceptions.TypeError
-None /= <MethodNumber 2> ... exceptions.TypeError
-None ** <MethodNumber 2> ... exceptions.TypeError
-None **= <MethodNumber 2> ... exceptions.TypeError
-None % <MethodNumber 2> ... exceptions.TypeError
-None %= <MethodNumber 2> ... exceptions.TypeError
-None + <CoerceNumber 2> ... exceptions.TypeError
-None += <CoerceNumber 2> ... exceptions.TypeError
-None - <CoerceNumber 2> ... exceptions.TypeError
-None -= <CoerceNumber 2> ... exceptions.TypeError
-None * <CoerceNumber 2> ... exceptions.TypeError
-None *= <CoerceNumber 2> ... exceptions.TypeError
-None / <CoerceNumber 2> ... exceptions.TypeError
-None /= <CoerceNumber 2> ... exceptions.TypeError
-None ** <CoerceNumber 2> ... exceptions.TypeError
-None **= <CoerceNumber 2> ... exceptions.TypeError
-None % <CoerceNumber 2> ... exceptions.TypeError
-None %= <CoerceNumber 2> ... exceptions.TypeError
-<MethodNumber 2> + 2 = 4
-<MethodNumber 2> += 2 => 4
-<MethodNumber 2> - 2 = 0
-<MethodNumber 2> -= 2 => 0
-<MethodNumber 2> * 2 = 4
-<MethodNumber 2> *= 2 => 4
-<MethodNumber 2> / 2 = 1
-<MethodNumber 2> /= 2 => 1
-<MethodNumber 2> ** 2 = 4
-<MethodNumber 2> **= 2 => 4
-<MethodNumber 2> % 2 = 0
-<MethodNumber 2> %= 2 => 0
-<MethodNumber 2> + 4.0 = 6.0
-<MethodNumber 2> += 4.0 => 6.0
-<MethodNumber 2> - 4.0 = -2.0
-<MethodNumber 2> -= 4.0 => -2.0
-<MethodNumber 2> * 4.0 = 8.0
-<MethodNumber 2> *= 4.0 => 8.0
-<MethodNumber 2> / 4.0 = 0.5
-<MethodNumber 2> /= 4.0 => 0.5
-<MethodNumber 2> ** 4.0 = 16.0
-<MethodNumber 2> **= 4.0 => 16.0
-<MethodNumber 2> % 4.0 = 2.0
-<MethodNumber 2> %= 4.0 => 2.0
-<MethodNumber 2> + 2 = 4
-<MethodNumber 2> += 2 => 4
-<MethodNumber 2> - 2 = 0
-<MethodNumber 2> -= 2 => 0
-<MethodNumber 2> * 2 = 4
-<MethodNumber 2> *= 2 => 4
-<MethodNumber 2> / 2 = 1
-<MethodNumber 2> /= 2 => 1
-<MethodNumber 2> ** 2 = 4
-<MethodNumber 2> **= 2 => 4
-<MethodNumber 2> % 2 = 0
-<MethodNumber 2> %= 2 => 0
-<MethodNumber 2> + (2+0j) = (4.0 + 0.0j)
-<MethodNumber 2> += (2+0j) => (4.0 + 0.0j)
-<MethodNumber 2> - (2+0j) = (0.0 + 0.0j)
-<MethodNumber 2> -= (2+0j) => (0.0 + 0.0j)
-<MethodNumber 2> * (2+0j) = (4.0 + 0.0j)
-<MethodNumber 2> *= (2+0j) => (4.0 + 0.0j)
-<MethodNumber 2> / (2+0j) = (1.0 + 0.0j)
-<MethodNumber 2> /= (2+0j) => (1.0 + 0.0j)
-<MethodNumber 2> ** (2+0j) = (4.0 + 0.0j)
-<MethodNumber 2> **= (2+0j) => (4.0 + 0.0j)
-<MethodNumber 2> % (2+0j) = (0.0 + 0.0j)
-<MethodNumber 2> %= (2+0j) => (0.0 + 0.0j)
-<MethodNumber 2> + [1] ... exceptions.TypeError
-<MethodNumber 2> += [1] ... exceptions.TypeError
-<MethodNumber 2> - [1] ... exceptions.TypeError
-<MethodNumber 2> -= [1] ... exceptions.TypeError
-<MethodNumber 2> * [1] = [1, 1]
-<MethodNumber 2> *= [1] => [1, 1]
-<MethodNumber 2> / [1] ... exceptions.TypeError
-<MethodNumber 2> /= [1] ... exceptions.TypeError
-<MethodNumber 2> ** [1] ... exceptions.TypeError
-<MethodNumber 2> **= [1] ... exceptions.TypeError
-<MethodNumber 2> % [1] ... exceptions.TypeError
-<MethodNumber 2> %= [1] ... exceptions.TypeError
-<MethodNumber 2> + (2,) ... exceptions.TypeError
-<MethodNumber 2> += (2,) ... exceptions.TypeError
-<MethodNumber 2> - (2,) ... exceptions.TypeError
-<MethodNumber 2> -= (2,) ... exceptions.TypeError
-<MethodNumber 2> * (2,) = (2, 2)
-<MethodNumber 2> *= (2,) => (2, 2)
-<MethodNumber 2> / (2,) ... exceptions.TypeError
-<MethodNumber 2> /= (2,) ... exceptions.TypeError
-<MethodNumber 2> ** (2,) ... exceptions.TypeError
-<MethodNumber 2> **= (2,) ... exceptions.TypeError
-<MethodNumber 2> % (2,) ... exceptions.TypeError
-<MethodNumber 2> %= (2,) ... exceptions.TypeError
-<MethodNumber 2> + None ... exceptions.TypeError
-<MethodNumber 2> += None ... exceptions.TypeError
-<MethodNumber 2> - None ... exceptions.TypeError
-<MethodNumber 2> -= None ... exceptions.TypeError
-<MethodNumber 2> * None ... exceptions.TypeError
-<MethodNumber 2> *= None ... exceptions.TypeError
-<MethodNumber 2> / None ... exceptions.TypeError
-<MethodNumber 2> /= None ... exceptions.TypeError
-<MethodNumber 2> ** None ... exceptions.TypeError
-<MethodNumber 2> **= None ... exceptions.TypeError
-<MethodNumber 2> % None ... exceptions.TypeError
-<MethodNumber 2> %= None ... exceptions.TypeError
-<MethodNumber 2> + <MethodNumber 2> = 4
-<MethodNumber 2> += <MethodNumber 2> => 4
-<MethodNumber 2> - <MethodNumber 2> = 0
-<MethodNumber 2> -= <MethodNumber 2> => 0
-<MethodNumber 2> * <MethodNumber 2> = 4
-<MethodNumber 2> *= <MethodNumber 2> => 4
-<MethodNumber 2> / <MethodNumber 2> = 1
-<MethodNumber 2> /= <MethodNumber 2> => 1
-<MethodNumber 2> ** <MethodNumber 2> = 4
-<MethodNumber 2> **= <MethodNumber 2> => 4
-<MethodNumber 2> % <MethodNumber 2> = 0
-<MethodNumber 2> %= <MethodNumber 2> => 0
-<MethodNumber 2> + <CoerceNumber 2> = 4
-<MethodNumber 2> += <CoerceNumber 2> => 4
-<MethodNumber 2> - <CoerceNumber 2> = 0
-<MethodNumber 2> -= <CoerceNumber 2> => 0
-<MethodNumber 2> * <CoerceNumber 2> = 4
-<MethodNumber 2> *= <CoerceNumber 2> => 4
-<MethodNumber 2> / <CoerceNumber 2> = 1
-<MethodNumber 2> /= <CoerceNumber 2> => 1
-<MethodNumber 2> ** <CoerceNumber 2> = 4
-<MethodNumber 2> **= <CoerceNumber 2> => 4
-<MethodNumber 2> % <CoerceNumber 2> = 0
-<MethodNumber 2> %= <CoerceNumber 2> => 0
-<CoerceNumber 2> + 2 = 4
-<CoerceNumber 2> += 2 => 4
-<CoerceNumber 2> - 2 = 0
-<CoerceNumber 2> -= 2 => 0
-<CoerceNumber 2> * 2 = 4
-<CoerceNumber 2> *= 2 => 4
-<CoerceNumber 2> / 2 = 1
-<CoerceNumber 2> /= 2 => 1
-<CoerceNumber 2> ** 2 = 4
-<CoerceNumber 2> **= 2 => 4
-<CoerceNumber 2> % 2 = 0
-<CoerceNumber 2> %= 2 => 0
-<CoerceNumber 2> + 4.0 = 6.0
-<CoerceNumber 2> += 4.0 => 6.0
-<CoerceNumber 2> - 4.0 = -2.0
-<CoerceNumber 2> -= 4.0 => -2.0
-<CoerceNumber 2> * 4.0 = 8.0
-<CoerceNumber 2> *= 4.0 => 8.0
-<CoerceNumber 2> / 4.0 = 0.5
-<CoerceNumber 2> /= 4.0 => 0.5
-<CoerceNumber 2> ** 4.0 = 16.0
-<CoerceNumber 2> **= 4.0 => 16.0
-<CoerceNumber 2> % 4.0 = 2.0
-<CoerceNumber 2> %= 4.0 => 2.0
-<CoerceNumber 2> + 2 = 4
-<CoerceNumber 2> += 2 => 4
-<CoerceNumber 2> - 2 = 0
-<CoerceNumber 2> -= 2 => 0
-<CoerceNumber 2> * 2 = 4
-<CoerceNumber 2> *= 2 => 4
-<CoerceNumber 2> / 2 = 1
-<CoerceNumber 2> /= 2 => 1
-<CoerceNumber 2> ** 2 = 4
-<CoerceNumber 2> **= 2 => 4
-<CoerceNumber 2> % 2 = 0
-<CoerceNumber 2> %= 2 => 0
-<CoerceNumber 2> + (2+0j) = (4.0 + 0.0j)
-<CoerceNumber 2> += (2+0j) => (4.0 + 0.0j)
-<CoerceNumber 2> - (2+0j) = (0.0 + 0.0j)
-<CoerceNumber 2> -= (2+0j) => (0.0 + 0.0j)
-<CoerceNumber 2> * (2+0j) = (4.0 + 0.0j)
-<CoerceNumber 2> *= (2+0j) => (4.0 + 0.0j)
-<CoerceNumber 2> / (2+0j) = (1.0 + 0.0j)
-<CoerceNumber 2> /= (2+0j) => (1.0 + 0.0j)
-<CoerceNumber 2> ** (2+0j) = (4.0 + 0.0j)
-<CoerceNumber 2> **= (2+0j) => (4.0 + 0.0j)
-<CoerceNumber 2> % (2+0j) = (0.0 + 0.0j)
-<CoerceNumber 2> %= (2+0j) => (0.0 + 0.0j)
-<CoerceNumber 2> + [1] ... exceptions.TypeError
-<CoerceNumber 2> += [1] ... exceptions.TypeError
-<CoerceNumber 2> - [1] ... exceptions.TypeError
-<CoerceNumber 2> -= [1] ... exceptions.TypeError
-<CoerceNumber 2> * [1] = [1, 1]
-<CoerceNumber 2> *= [1] => [1, 1]
-<CoerceNumber 2> / [1] ... exceptions.TypeError
-<CoerceNumber 2> /= [1] ... exceptions.TypeError
-<CoerceNumber 2> ** [1] ... exceptions.TypeError
-<CoerceNumber 2> **= [1] ... exceptions.TypeError
-<CoerceNumber 2> % [1] ... exceptions.TypeError
-<CoerceNumber 2> %= [1] ... exceptions.TypeError
-<CoerceNumber 2> + (2,) ... exceptions.TypeError
-<CoerceNumber 2> += (2,) ... exceptions.TypeError
-<CoerceNumber 2> - (2,) ... exceptions.TypeError
-<CoerceNumber 2> -= (2,) ... exceptions.TypeError
-<CoerceNumber 2> * (2,) = (2, 2)
-<CoerceNumber 2> *= (2,) => (2, 2)
-<CoerceNumber 2> / (2,) ... exceptions.TypeError
-<CoerceNumber 2> /= (2,) ... exceptions.TypeError
-<CoerceNumber 2> ** (2,) ... exceptions.TypeError
-<CoerceNumber 2> **= (2,) ... exceptions.TypeError
-<CoerceNumber 2> % (2,) ... exceptions.TypeError
-<CoerceNumber 2> %= (2,) ... exceptions.TypeError
-<CoerceNumber 2> + None ... exceptions.TypeError
-<CoerceNumber 2> += None ... exceptions.TypeError
-<CoerceNumber 2> - None ... exceptions.TypeError
-<CoerceNumber 2> -= None ... exceptions.TypeError
-<CoerceNumber 2> * None ... exceptions.TypeError
-<CoerceNumber 2> *= None ... exceptions.TypeError
-<CoerceNumber 2> / None ... exceptions.TypeError
-<CoerceNumber 2> /= None ... exceptions.TypeError
-<CoerceNumber 2> ** None ... exceptions.TypeError
-<CoerceNumber 2> **= None ... exceptions.TypeError
-<CoerceNumber 2> % None ... exceptions.TypeError
-<CoerceNumber 2> %= None ... exceptions.TypeError
-<CoerceNumber 2> + <MethodNumber 2> = 4
-<CoerceNumber 2> += <MethodNumber 2> => 4
-<CoerceNumber 2> - <MethodNumber 2> = 0
-<CoerceNumber 2> -= <MethodNumber 2> => 0
-<CoerceNumber 2> * <MethodNumber 2> = 4
-<CoerceNumber 2> *= <MethodNumber 2> => 4
-<CoerceNumber 2> / <MethodNumber 2> = 1
-<CoerceNumber 2> /= <MethodNumber 2> => 1
-<CoerceNumber 2> ** <MethodNumber 2> = 4
-<CoerceNumber 2> **= <MethodNumber 2> => 4
-<CoerceNumber 2> % <MethodNumber 2> = 0
-<CoerceNumber 2> %= <MethodNumber 2> => 0
-<CoerceNumber 2> + <CoerceNumber 2> = 4
-<CoerceNumber 2> += <CoerceNumber 2> => 4
-<CoerceNumber 2> - <CoerceNumber 2> = 0
-<CoerceNumber 2> -= <CoerceNumber 2> => 0
-<CoerceNumber 2> * <CoerceNumber 2> = 4
-<CoerceNumber 2> *= <CoerceNumber 2> => 4
-<CoerceNumber 2> / <CoerceNumber 2> = 1
-<CoerceNumber 2> /= <CoerceNumber 2> => 1
-<CoerceNumber 2> ** <CoerceNumber 2> = 4
-<CoerceNumber 2> **= <CoerceNumber 2> => 4
-<CoerceNumber 2> % <CoerceNumber 2> = 0
-<CoerceNumber 2> %= <CoerceNumber 2> => 0
-divmod(2, 2) = (1, 0)
-divmod(2, 4.0) = (0.0, 2.0)
-divmod(2, 2) = (1L, 0L)
-divmod(2, (2+0j)) = ((1+0j), 0j)
-divmod(2, [1]) ... exceptions.TypeError
-divmod(2, (2,)) ... exceptions.TypeError
-divmod(2, None) ... exceptions.TypeError
-divmod(2, <MethodNumber 2>) ... exceptions.TypeError
-divmod(2, <CoerceNumber 2>) = (1, 0)
-divmod(4.0, 2) = (2.0, 0.0)
-divmod(4.0, 4.0) = (1.0, 0.0)
-divmod(4.0, 2) = (2.0, 0.0)
-divmod(4.0, (2+0j)) = ((2+0j), 0j)
-divmod(4.0, [1]) ... exceptions.TypeError
-divmod(4.0, (2,)) ... exceptions.TypeError
-divmod(4.0, None) ... exceptions.TypeError
-divmod(4.0, <MethodNumber 2>) ... exceptions.TypeError
-divmod(4.0, <CoerceNumber 2>) = (2.0, 0.0)
-divmod(2, 2) = (1L, 0L)
-divmod(2, 4.0) = (0.0, 2.0)
-divmod(2, 2) = (1L, 0L)
-divmod(2, (2+0j)) = ((1+0j), 0j)
-divmod(2, [1]) ... exceptions.TypeError
-divmod(2, (2,)) ... exceptions.TypeError
-divmod(2, None) ... exceptions.TypeError
-divmod(2, <MethodNumber 2>) ... exceptions.TypeError
-divmod(2, <CoerceNumber 2>) = (1L, 0L)
-divmod((2+0j), 2) = ((1+0j), 0j)
-divmod((2+0j), 4.0) = (0j, (2+0j))
-divmod((2+0j), 2) = ((1+0j), 0j)
-divmod((2+0j), (2+0j)) = ((1+0j), 0j)
-divmod((2+0j), [1]) ... exceptions.TypeError
-divmod((2+0j), (2,)) ... exceptions.TypeError
-divmod((2+0j), None) ... exceptions.TypeError
-divmod((2+0j), <MethodNumber 2>) ... exceptions.TypeError
-divmod((2+0j), <CoerceNumber 2>) = ((1+0j), 0j)
-divmod([1], 2) ... exceptions.TypeError
-divmod([1], 4.0) ... exceptions.TypeError
-divmod([1], 2) ... exceptions.TypeError
-divmod([1], (2+0j)) ... exceptions.TypeError
-divmod([1], [1]) ... exceptions.TypeError
-divmod([1], (2,)) ... exceptions.TypeError
-divmod([1], None) ... exceptions.TypeError
-divmod([1], <MethodNumber 2>) ... exceptions.TypeError
-divmod([1], <CoerceNumber 2>) ... exceptions.TypeError
-divmod((2,), 2) ... exceptions.TypeError
-divmod((2,), 4.0) ... exceptions.TypeError
-divmod((2,), 2) ... exceptions.TypeError
-divmod((2,), (2+0j)) ... exceptions.TypeError
-divmod((2,), [1]) ... exceptions.TypeError
-divmod((2,), (2,)) ... exceptions.TypeError
-divmod((2,), None) ... exceptions.TypeError
-divmod((2,), <MethodNumber 2>) ... exceptions.TypeError
-divmod((2,), <CoerceNumber 2>) ... exceptions.TypeError
-divmod(None, 2) ... exceptions.TypeError
-divmod(None, 4.0) ... exceptions.TypeError
-divmod(None, 2) ... exceptions.TypeError
-divmod(None, (2+0j)) ... exceptions.TypeError
-divmod(None, [1]) ... exceptions.TypeError
-divmod(None, (2,)) ... exceptions.TypeError
-divmod(None, None) ... exceptions.TypeError
-divmod(None, <MethodNumber 2>) ... exceptions.TypeError
-divmod(None, <CoerceNumber 2>) ... exceptions.TypeError
-divmod(<MethodNumber 2>, 2) ... exceptions.TypeError
-divmod(<MethodNumber 2>, 4.0) ... exceptions.TypeError
-divmod(<MethodNumber 2>, 2) ... exceptions.TypeError
-divmod(<MethodNumber 2>, (2+0j)) ... exceptions.TypeError
-divmod(<MethodNumber 2>, [1]) ... exceptions.TypeError
-divmod(<MethodNumber 2>, (2,)) ... exceptions.TypeError
-divmod(<MethodNumber 2>, None) ... exceptions.TypeError
-divmod(<MethodNumber 2>, <MethodNumber 2>) ... exceptions.TypeError
-divmod(<MethodNumber 2>, <CoerceNumber 2>) ... exceptions.TypeError
-divmod(<CoerceNumber 2>, 2) = (1, 0)
-divmod(<CoerceNumber 2>, 4.0) = (0.0, 2.0)
-divmod(<CoerceNumber 2>, 2) = (1L, 0L)
-divmod(<CoerceNumber 2>, (2+0j)) = ((1+0j), 0j)
-divmod(<CoerceNumber 2>, [1]) ... exceptions.TypeError
-divmod(<CoerceNumber 2>, (2,)) ... exceptions.TypeError
-divmod(<CoerceNumber 2>, None) ... exceptions.TypeError
-divmod(<CoerceNumber 2>, <MethodNumber 2>) ... exceptions.TypeError
-divmod(<CoerceNumber 2>, <CoerceNumber 2>) = (1, 0)
diff --git a/Lib/test/output/test_compare b/Lib/test/output/test_compare
deleted file mode 100644
index 210bd97..0000000
--- a/Lib/test/output/test_compare
+++ /dev/null
@@ -1,101 +0,0 @@
-test_compare
-2 == 2
-2 == 2.0
-2 == 2
-2 == (2+0j)
-2 != [1]
-2 != (3,)
-2 != None
-2 != <Empty>
-2 == <Coerce 2>
-2 == <Cmp 2.0>
-2.0 == 2
-2.0 == 2.0
-2.0 == 2
-2.0 == (2+0j)
-2.0 != [1]
-2.0 != (3,)
-2.0 != None
-2.0 != <Empty>
-2.0 == <Coerce 2>
-2.0 == <Cmp 2.0>
-2 == 2
-2 == 2.0
-2 == 2
-2 == (2+0j)
-2 != [1]
-2 != (3,)
-2 != None
-2 != <Empty>
-2 == <Coerce 2>
-2 == <Cmp 2.0>
-(2+0j) == 2
-(2+0j) == 2.0
-(2+0j) == 2
-(2+0j) == (2+0j)
-(2+0j) != [1]
-(2+0j) != (3,)
-(2+0j) != None
-(2+0j) != <Empty>
-(2+0j) == <Coerce 2>
-(2+0j) == <Cmp 2.0>
-[1] != 2
-[1] != 2.0
-[1] != 2
-[1] != (2+0j)
-[1] == [1]
-[1] != (3,)
-[1] != None
-[1] != <Empty>
-[1] != <Coerce 2>
-[1] != <Cmp 2.0>
-(3,) != 2
-(3,) != 2.0
-(3,) != 2
-(3,) != (2+0j)
-(3,) != [1]
-(3,) == (3,)
-(3,) != None
-(3,) != <Empty>
-(3,) != <Coerce 2>
-(3,) != <Cmp 2.0>
-None != 2
-None != 2.0
-None != 2
-None != (2+0j)
-None != [1]
-None != (3,)
-None == None
-None != <Empty>
-None != <Coerce 2>
-None != <Cmp 2.0>
-<Empty> != 2
-<Empty> != 2.0
-<Empty> != 2
-<Empty> != (2+0j)
-<Empty> != [1]
-<Empty> != (3,)
-<Empty> != None
-<Empty> == <Empty>
-<Empty> != <Coerce 2>
-<Empty> != <Cmp 2.0>
-<Coerce 2> == 2
-<Coerce 2> == 2.0
-<Coerce 2> == 2
-<Coerce 2> == (2+0j)
-<Coerce 2> != [1]
-<Coerce 2> != (3,)
-<Coerce 2> != None
-<Coerce 2> != <Empty>
-<Coerce 2> == <Coerce 2>
-<Coerce 2> == <Cmp 2.0>
-<Cmp 2.0> == 2
-<Cmp 2.0> == 2.0
-<Cmp 2.0> == 2
-<Cmp 2.0> == (2+0j)
-<Cmp 2.0> != [1]
-<Cmp 2.0> != (3,)
-<Cmp 2.0> != None
-<Cmp 2.0> != <Empty>
-<Cmp 2.0> == <Coerce 2>
-<Cmp 2.0> == <Cmp 2.0>
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 85f57a6..566e54b 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -520,7 +520,7 @@
                 import gc
                 def cleanup():
                     import _strptime, linecache, warnings, dircache
-                    import urlparse, urllib, urllib2
+                    import urlparse, urllib, urllib2, mimetypes, doctest
                     from distutils.dir_util import _path_created
                     _path_created.clear()
                     warnings.filters[:] = fs
@@ -536,6 +536,8 @@
                     sys.path_importer_cache.update(pic)
                     dircache.reset()
                     linecache.clearcache()
+                    mimetypes._default_mime_types()
+                    doctest.master = None
                 if indirect_test:
                     def run_the_test():
                         indirect_test()
@@ -547,6 +549,7 @@
                 print >> sys.stderr, "beginning", repcount, "repetitions"
                 print >> sys.stderr, \
                       ("1234567890"*(repcount//10 + 1))[:repcount]
+                cleanup()
                 for i in range(repcount):
                     rc = sys.gettotalrefcount()
                     run_the_test()
@@ -744,6 +747,8 @@
         test_sunaudiodev
         test_threadsignals
         test_timing
+        test_wait3
+        test_wait4
         """,
     'linux2':
         """
@@ -761,6 +766,8 @@
         test_nis
         test_ntpath
         test_ossaudiodev
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         """,
    'mac':
@@ -800,6 +807,8 @@
         test_pwd
         test_resource
         test_signal
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         test_sundry
         test_tarfile
@@ -824,6 +833,8 @@
         test_openpty
         test_pyexpat
         test_sax
+        test_startfile
+        test_sqlite
         test_sunaudiodev
         test_sundry
         """,
@@ -846,6 +857,8 @@
         test_openpty
         test_pyexpat
         test_sax
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         test_sundry
         """,
@@ -873,6 +886,8 @@
         test_pyexpat
         test_queue
         test_sax
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         test_sundry
         test_thread
@@ -913,6 +928,8 @@
         test_pty
         test_pwd
         test_strop
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         test_sundry
         test_thread
@@ -930,7 +947,6 @@
         test_cd
         test_cl
         test_curses
-        test_dl
         test_gdbm
         test_gl
         test_imgfile
@@ -942,6 +958,8 @@
         test_ntpath
         test_ossaudiodev
         test_poll
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         """,
     'sunos5':
@@ -960,6 +978,8 @@
         test_imgfile
         test_linuxaudiodev
         test_openpty
+        test_sqlite
+        test_startfile
         test_zipfile
         test_zlib
         """,
@@ -986,6 +1006,8 @@
         test_openpty
         test_pyexpat
         test_sax
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         test_zipfile
         test_zlib
@@ -1011,6 +1033,8 @@
         test_poll
         test_popen2
         test_resource
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         """,
     'cygwin':
@@ -1032,6 +1056,7 @@
         test_nis
         test_ossaudiodev
         test_socketserver
+        test_sqlite
         test_sunaudiodev
         """,
     'os2emx':
@@ -1058,6 +1083,8 @@
         test_pty
         test_resource
         test_signal
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         """,
     'freebsd4':
@@ -1084,6 +1111,8 @@
         test_scriptpackages
         test_socket_ssl
         test_socketserver
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         test_tcl
         test_timeout
@@ -1113,6 +1142,8 @@
         test_macostools
         test_nis
         test_ossaudiodev
+        test_sqlite
+        test_startfile
         test_sunaudiodev
         test_tcl
         test_winreg
@@ -1120,6 +1151,38 @@
         test_zipimport
         test_zlib
         """,
+    'openbsd3':
+        """
+        test_aepack
+        test_al
+        test_applesingle
+        test_bsddb
+        test_bsddb3
+        test_cd
+        test_cl
+        test_ctypes
+        test_dl
+        test_gdbm
+        test_gl
+        test_imgfile
+        test_linuxaudiodev
+        test_locale
+        test_macfs
+        test_macostools
+        test_nis
+        test_normalization
+        test_ossaudiodev
+        test_pep277
+        test_plistlib
+        test_scriptpackages
+        test_tcl
+        test_sqlite
+        test_startfile
+        test_sunaudiodev
+        test_unicode_file
+        test_winreg
+        test_winsound
+        """,
 }
 _expectations['freebsd5'] = _expectations['freebsd4']
 _expectations['freebsd6'] = _expectations['freebsd4']
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 0b2e7da..c45e139 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -5,8 +5,6 @@
 import sys
 import warnings
 
-warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
-                        r'^regsub$')
 warnings.filterwarnings("ignore",
                         "the gopherlib module is deprecated",
                         DeprecationWarning,
@@ -128,8 +126,6 @@
         self.check_all("quopri")
         self.check_all("random")
         self.check_all("re")
-        self.check_all("reconvert")
-        self.check_all("regsub")
         self.check_all("repr")
         self.check_all("rexec")
         self.check_all("rfc822")
diff --git a/Lib/test/test_applesingle.py b/Lib/test/test_applesingle.py
index 2a2d60a..d533f1a 100644
--- a/Lib/test/test_applesingle.py
+++ b/Lib/test/test_applesingle.py
@@ -15,8 +15,8 @@
 dataforkdata = 'hello\r\0world\n'
 resourceforkdata = 'goodbye\ncruel\0world\r'
 
-applesingledata = struct.pack("ll16sh", AS_MAGIC, AS_VERSION, "foo", 2) + \
-    struct.pack("llllll", 1, 50, len(dataforkdata),
+applesingledata = struct.pack(">ll16sh", AS_MAGIC, AS_VERSION, "foo", 2) + \
+    struct.pack(">llllll", 1, 50, len(dataforkdata),
         2, 50+len(dataforkdata), len(resourceforkdata)) + \
     dataforkdata + \
     resourceforkdata
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 87d395d..62361fc 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -61,7 +61,7 @@
         bi = a.buffer_info()
         self.assert_(isinstance(bi, tuple))
         self.assertEqual(len(bi), 2)
-        self.assert_(isinstance(bi[0], int))
+        self.assert_(isinstance(bi[0], (int, long)))
         self.assert_(isinstance(bi[1], int))
         self.assertEqual(bi[1], len(a))
 
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index b42caa3..c64ad28 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -119,7 +119,8 @@
 # excepthandler, arguments, keywords, alias
 
 if __name__=='__main__' and sys.argv[1:] == ['-g']:
-    for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), (eval_tests, "eval")):
+    for statements, kind in ((exec_tests, "exec"), (single_tests, "single"),
+                             (eval_tests, "eval")):
         print kind+"_results = ["
         for s in statements:
             print repr(to_tuple(compile(s, "?", kind, 0x400)))+","
@@ -131,7 +132,7 @@
 
     if not isinstance(ast_node, _ast.AST) or ast_node._fields == None:
         return
-    if isinstance(ast_node, (_ast.expr, _ast.stmt)):
+    if isinstance(ast_node, (_ast.expr, _ast.stmt, _ast.excepthandler)):
         node_pos = (ast_node.lineno, ast_node.col_offset)
         assert node_pos >= parent_pos, (node_pos, parent_pos)
         parent_pos = (ast_node.lineno, ast_node.col_offset)
@@ -145,8 +146,8 @@
 
 def run_tests():
     for input, output, kind in ((exec_tests, exec_results, "exec"),
-                                        (single_tests, single_results, "single"),
-                                        (eval_tests, eval_results, "eval")):
+                                (single_tests, single_results, "single"),
+                                (eval_tests, eval_results, "eval")):
         for i, o in itertools.izip(input, output):
             ast_tree = compile(i, "?", kind, 0x400)
             assert to_tuple(ast_tree) == o
@@ -165,7 +166,7 @@
 ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]),
 ('Module', [('If', (1, 0), ('Name', (1, 3), 'v', ('Load',)), [('Pass', (1, 5))], [])]),
 ('Module', [('Raise', (1, 0), ('Name', (1, 6), 'Exception', ('Load',)), ('Str', (1, 17), 'string'), None)]),
-('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('excepthandler', ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))])], [])]),
+('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('excepthandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))], 3, 0)], [])]),
 ('Module', [('TryFinally', (1, 0), [('Pass', (2, 2))], [('Pass', (4, 2))])]),
 ('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]),
 ('Module', [('Import', (1, 0), [('alias', 'sys', None)])]),
diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py
index 440adab..f585733 100644
--- a/Lib/test/test_audioop.py
+++ b/Lib/test/test_audioop.py
@@ -136,12 +136,30 @@
         return 0
     return 1
 
+def testlin2alaw(data):
+    if verbose:
+        print 'lin2alaw'
+    if audioop.lin2alaw(data[0], 1) != '\xd5\xc5\xf5' or \
+              audioop.lin2alaw(data[1], 2) != '\xd5\xd5\xd5' or \
+              audioop.lin2alaw(data[2], 4) != '\xd5\xd5\xd5':
+        return 0
+    return 1
+
+def testalaw2lin(data):
+    if verbose:
+        print 'alaw2lin'
+    # Cursory
+    d = audioop.lin2alaw(data[0], 1)
+    if audioop.alaw2lin(d, 1) != data[0]:
+        return 0
+    return 1
+
 def testlin2ulaw(data):
     if verbose:
         print 'lin2ulaw'
-    if audioop.lin2ulaw(data[0], 1) != '\377\347\333' or \
-              audioop.lin2ulaw(data[1], 2) != '\377\377\377' or \
-              audioop.lin2ulaw(data[2], 4) != '\377\377\377':
+    if audioop.lin2ulaw(data[0], 1) != '\xff\xe7\xdb' or \
+              audioop.lin2ulaw(data[1], 2) != '\xff\xff\xff' or \
+              audioop.lin2ulaw(data[2], 4) != '\xff\xff\xff':
         return 0
     return 1
 
diff --git a/Lib/test/test_augassign.py b/Lib/test/test_augassign.py
index 22cca44..0309d6e 100644
--- a/Lib/test/test_augassign.py
+++ b/Lib/test/test_augassign.py
@@ -1,258 +1,312 @@
 # Augmented assignment test.
 
-x = 2
-x += 1
-x *= 2
-x **= 2
-x -= 8
-x %= 12
-x >>= 1
-x &= 2
-x |= 5
-x ^= 1
-x <<= 2
-x /= 2
-x //= 2
-
-print x
-print int(x)
-
-x = [2]
-x[0] += 1
-x[0] *= 2
-x[0] **= 2
-x[0] -= 8
-x[0] %= 12
-x[0] >>= 1
-x[0] &= 2
-x[0] |= 5
-x[0] ^= 1
-x[0] <<= 2
-x[0] /= 2
-x[0] //= 2
-
-print x
-print int(x[0])
-
-x = {0: 2}
-x[0] += 1
-x[0] *= 2
-x[0] **= 2
-x[0] -= 8
-x[0] %= 12
-x[0] >>= 1
-x[0] &= 2
-x[0] |= 5
-x[0] ^= 1
-x[0] <<= 2
-x[0] /= 2
-x[0] //= 2
-
-print x[0]
-print int(x[0])
-
-x = [1,2]
-x += [3,4]
-x *= 2
-
-print x
-
-x = [1, 2, 3]
-y = x
-x[1:2] *= 2
-y[1:2] += [1]
-
-print x
-print x is y
-
-class aug_test:
-    def __init__(self, value):
-        self.val = value
-    def __radd__(self, val):
-        return self.val + val
-    def __add__(self, val):
-        return aug_test(self.val + val)
+from test.test_support import run_unittest
+import unittest
 
 
-class aug_test2(aug_test):
-    def __iadd__(self, val):
-        self.val = self.val + val
-        return self
+class AugAssignTest(unittest.TestCase):
+    def testBasic(self):
+        x = 2
+        x += 1
+        x *= 2
+        x **= 2
+        x -= 8
+        x //= 5
+        x %= 3
+        x &= 2
+        x |= 5
+        x ^= 1
+        x /= 2
+        self.assertEquals(x, 3.0)
 
-class aug_test3(aug_test):
-    def __iadd__(self, val):
-        return aug_test3(self.val + val)
+    def testInList(self):
+        x = [2]
+        x[0] += 1
+        x[0] *= 2
+        x[0] **= 2
+        x[0] -= 8
+        x[0] //= 5
+        x[0] %= 3
+        x[0] &= 2
+        x[0] |= 5
+        x[0] ^= 1
+        x[0] /= 2
+        self.assertEquals(x[0], 3.0)
 
-x = aug_test(1)
-y = x
-x += 10
+    def testInDict(self):
+        x = {0: 2}
+        x[0] += 1
+        x[0] *= 2
+        x[0] **= 2
+        x[0] -= 8
+        x[0] //= 5
+        x[0] %= 3
+        x[0] &= 2
+        x[0] |= 5
+        x[0] ^= 1
+        x[0] /= 2
+        self.assertEquals(x[0], 3.0)
 
-print isinstance(x, aug_test)
-print y is not x
-print x.val
+    def testSequences(self):
+        x = [1,2]
+        x += [3,4]
+        x *= 2
 
-x = aug_test2(2)
-y = x
-x += 10
+        self.assertEquals(x, [1, 2, 3, 4, 1, 2, 3, 4])
 
-print y is x
-print x.val
+        x = [1, 2, 3]
+        y = x
+        x[1:2] *= 2
+        y[1:2] += [1]
 
-x = aug_test3(3)
-y = x
-x += 10
+        self.assertEquals(x, [1, 2, 1, 2, 3])
+        self.assert_(x is y)
 
-print isinstance(x, aug_test3)
-print y is not x
-print x.val
+    def testCustomMethods1(self):
 
-class testall:
+        class aug_test:
+            def __init__(self, value):
+                self.val = value
+            def __radd__(self, val):
+                return self.val + val
+            def __add__(self, val):
+                return aug_test(self.val + val)
 
-    def __add__(self, val):
-        print "__add__ called"
-    def __radd__(self, val):
-        print "__radd__ called"
-    def __iadd__(self, val):
-        print "__iadd__ called"
-        return self
+        class aug_test2(aug_test):
+            def __iadd__(self, val):
+                self.val = self.val + val
+                return self
 
-    def __sub__(self, val):
-        print "__sub__ called"
-    def __rsub__(self, val):
-        print "__rsub__ called"
-    def __isub__(self, val):
-        print "__isub__ called"
-        return self
+        class aug_test3(aug_test):
+            def __iadd__(self, val):
+                return aug_test3(self.val + val)
 
-    def __mul__(self, val):
-        print "__mul__ called"
-    def __rmul__(self, val):
-        print "__rmul__ called"
-    def __imul__(self, val):
-        print "__imul__ called"
-        return self
+        x = aug_test(1)
+        y = x
+        x += 10
 
-    def __floordiv__(self, val):
-        print "__floordiv__ called"
-        return self
-    def __ifloordiv__(self, val):
-        print "__ifloordiv__ called"
-        return self
-    def __rfloordiv__(self, val):
-        print "__rfloordiv__ called"
-        return self
+        self.assert_(isinstance(x, aug_test))
+        self.assert_(y is not x)
+        self.assertEquals(x.val, 11)
 
-    def __truediv__(self, val):
-        print "__truediv__ called"
-        return self
-    def __itruediv__(self, val):
-        print "__itruediv__ called"
-        return self
-    def __rtruediv__(self, val):
-        print "__rtruediv__ called"
-        return self
+        x = aug_test2(2)
+        y = x
+        x += 10
 
-    def __mod__(self, val):
-        print "__mod__ called"
-    def __rmod__(self, val):
-        print "__rmod__ called"
-    def __imod__(self, val):
-        print "__imod__ called"
-        return self
+        self.assert_(y is x)
+        self.assertEquals(x.val, 12)
 
-    def __pow__(self, val):
-        print "__pow__ called"
-    def __rpow__(self, val):
-        print "__rpow__ called"
-    def __ipow__(self, val):
-        print "__ipow__ called"
-        return self
+        x = aug_test3(3)
+        y = x
+        x += 10
 
-    def __or__(self, val):
-        print "__or__ called"
-    def __ror__(self, val):
-        print "__ror__ called"
-    def __ior__(self, val):
-        print "__ior__ called"
-        return self
+        self.assert_(isinstance(x, aug_test3))
+        self.assert_(y is not x)
+        self.assertEquals(x.val, 13)
 
-    def __and__(self, val):
-        print "__and__ called"
-    def __rand__(self, val):
-        print "__rand__ called"
-    def __iand__(self, val):
-        print "__iand__ called"
-        return self
 
-    def __xor__(self, val):
-        print "__xor__ called"
-    def __rxor__(self, val):
-        print "__rxor__ called"
-    def __ixor__(self, val):
-        print "__ixor__ called"
-        return self
+    def testCustomMethods2(test_self):
+        output = []
 
-    def __rshift__(self, val):
-        print "__rshift__ called"
-    def __rrshift__(self, val):
-        print "__rrshift__ called"
-    def __irshift__(self, val):
-        print "__irshift__ called"
-        return self
+        class testall:
+            def __add__(self, val):
+                output.append("__add__ called")
+            def __radd__(self, val):
+                output.append("__radd__ called")
+            def __iadd__(self, val):
+                output.append("__iadd__ called")
+                return self
 
-    def __lshift__(self, val):
-        print "__lshift__ called"
-    def __rlshift__(self, val):
-        print "__rlshift__ called"
-    def __ilshift__(self, val):
-        print "__ilshift__ called"
-        return self
+            def __sub__(self, val):
+                output.append("__sub__ called")
+            def __rsub__(self, val):
+                output.append("__rsub__ called")
+            def __isub__(self, val):
+                output.append("__isub__ called")
+                return self
 
-x = testall()
-x + 1
-1 + x
-x += 1
+            def __mul__(self, val):
+                output.append("__mul__ called")
+            def __rmul__(self, val):
+                output.append("__rmul__ called")
+            def __imul__(self, val):
+                output.append("__imul__ called")
+                return self
 
-x - 1
-1 - x
-x -= 1
+            def __div__(self, val):
+                output.append("__div__ called")
+            def __rdiv__(self, val):
+                output.append("__rdiv__ called")
+            def __idiv__(self, val):
+                output.append("__idiv__ called")
+                return self
 
-x * 1
-1 * x
-x *= 1
+            def __floordiv__(self, val):
+                output.append("__floordiv__ called")
+                return self
+            def __ifloordiv__(self, val):
+                output.append("__ifloordiv__ called")
+                return self
+            def __rfloordiv__(self, val):
+                output.append("__rfloordiv__ called")
+                return self
 
-x / 1
-1 / x
-x /= 1
+            def __truediv__(self, val):
+                output.append("__truediv__ called")
+                return self
+            def __rtruediv__(self, val):
+                output.append("__rtruediv__ called")
+                return self
+            def __itruediv__(self, val):
+                output.append("__itruediv__ called")
+                return self
 
-x // 1
-1 // x
-x //= 1
+            def __mod__(self, val):
+                output.append("__mod__ called")
+            def __rmod__(self, val):
+                output.append("__rmod__ called")
+            def __imod__(self, val):
+                output.append("__imod__ called")
+                return self
 
-x % 1
-1 % x
-x %= 1
+            def __pow__(self, val):
+                output.append("__pow__ called")
+            def __rpow__(self, val):
+                output.append("__rpow__ called")
+            def __ipow__(self, val):
+                output.append("__ipow__ called")
+                return self
 
-x ** 1
-1 ** x
-x **= 1
+            def __or__(self, val):
+                output.append("__or__ called")
+            def __ror__(self, val):
+                output.append("__ror__ called")
+            def __ior__(self, val):
+                output.append("__ior__ called")
+                return self
 
-x | 1
-1 | x
-x |= 1
+            def __and__(self, val):
+                output.append("__and__ called")
+            def __rand__(self, val):
+                output.append("__rand__ called")
+            def __iand__(self, val):
+                output.append("__iand__ called")
+                return self
 
-x & 1
-1 & x
-x &= 1
+            def __xor__(self, val):
+                output.append("__xor__ called")
+            def __rxor__(self, val):
+                output.append("__rxor__ called")
+            def __ixor__(self, val):
+                output.append("__ixor__ called")
+                return self
 
-x ^ 1
-1 ^ x
-x ^= 1
+            def __rshift__(self, val):
+                output.append("__rshift__ called")
+            def __rrshift__(self, val):
+                output.append("__rrshift__ called")
+            def __irshift__(self, val):
+                output.append("__irshift__ called")
+                return self
 
-x >> 1
-1 >> x
-x >>= 1
+            def __lshift__(self, val):
+                output.append("__lshift__ called")
+            def __rlshift__(self, val):
+                output.append("__rlshift__ called")
+            def __ilshift__(self, val):
+                output.append("__ilshift__ called")
+                return self
 
-x << 1
-1 << x
-x <<= 1
+        x = testall()
+        x + 1
+        1 + x
+        x += 1
+
+        x - 1
+        1 - x
+        x -= 1
+
+        x * 1
+        1 * x
+        x *= 1
+
+        x / 1
+        1 / x
+        x /= 1
+
+        x // 1
+        1 // x
+        x //= 1
+
+        x % 1
+        1 % x
+        x %= 1
+
+        x ** 1
+        1 ** x
+        x **= 1
+
+        x | 1
+        1 | x
+        x |= 1
+
+        x & 1
+        1 & x
+        x &= 1
+
+        x ^ 1
+        1 ^ x
+        x ^= 1
+
+        x >> 1
+        1 >> x
+        x >>= 1
+
+        x << 1
+        1 << x
+        x <<= 1
+
+        test_self.assertEquals(output, '''\
+__add__ called
+__radd__ called
+__iadd__ called
+__sub__ called
+__rsub__ called
+__isub__ called
+__mul__ called
+__rmul__ called
+__imul__ called
+__truediv__ called
+__rtruediv__ called
+__itruediv__ called
+__floordiv__ called
+__rfloordiv__ called
+__ifloordiv__ called
+__mod__ called
+__rmod__ called
+__imod__ called
+__pow__ called
+__rpow__ called
+__ipow__ called
+__or__ called
+__ror__ called
+__ior__ called
+__and__ called
+__rand__ called
+__iand__ called
+__xor__ called
+__rxor__ called
+__ixor__ called
+__rshift__ called
+__rrshift__ called
+__irshift__ called
+__lshift__ called
+__rlshift__ called
+__ilshift__ called
+'''.splitlines())
+
+def test_main():
+    run_unittest(AugAssignTest)
+
+if __name__ == '__main__':
+    test_main()
diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py
index 1ec4801..513e541 100755
--- a/Lib/test/test_bsddb.py
+++ b/Lib/test/test_bsddb.py
@@ -11,9 +11,10 @@
 from sets import Set
 
 class TestBSDDB(unittest.TestCase):
+    openflag = 'c'
 
     def setUp(self):
-        self.f = self.openmethod[0](self.fname, 'c')
+        self.f = self.openmethod[0](self.fname, self.openflag, cachesize=32768)
         self.d = dict(q='Guido', w='van', e='Rossum', r='invented', t='Python', y='')
         for k, v in self.d.iteritems():
             self.f[k] = v
@@ -267,6 +268,11 @@
     fname = None
     openmethod = [bsddb.btopen]
 
+class TestBTree_InMemory_Truncate(TestBSDDB):
+    fname = None
+    openflag = 'n'
+    openmethod = [bsddb.btopen]
+
 class TestHashTable(TestBSDDB):
     fname = test_support.TESTFN
     openmethod = [bsddb.hashopen]
@@ -285,6 +291,7 @@
         TestHashTable,
         TestBTree_InMemory,
         TestHashTable_InMemory,
+        TestBTree_InMemory_Truncate,
     )
 
 if __name__ == "__main__":
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 6f11fdd..ef4f407 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -108,6 +108,7 @@
         __import__('string')
         self.assertRaises(ImportError, __import__, 'spamspam')
         self.assertRaises(TypeError, __import__, 1, 2, 3, 4)
+        self.assertRaises(ValueError, __import__, '')
 
     def test_abs(self):
         # int
@@ -1317,6 +1318,9 @@
 
         self.assertEqual(round(-8.0, -1), -10.0)
 
+        # test new kwargs
+        self.assertEqual(round(number=-8.0, ndigits=-1), -10.0)
+
         self.assertRaises(TypeError, round)
 
     def test_setattr(self):
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index 34d365b..e414324 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -4,6 +4,202 @@
 from test import test_support
 
 
+result_2004_text = """
+                                  2004
+
+      January                   February                   March
+Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
+          1  2  3  4                         1       1  2  3  4  5  6  7
+ 5  6  7  8  9 10 11       2  3  4  5  6  7  8       8  9 10 11 12 13 14
+12 13 14 15 16 17 18       9 10 11 12 13 14 15      15 16 17 18 19 20 21
+19 20 21 22 23 24 25      16 17 18 19 20 21 22      22 23 24 25 26 27 28
+26 27 28 29 30 31         23 24 25 26 27 28 29      29 30 31
+
+       April                      May                       June
+Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
+          1  2  3  4                      1  2          1  2  3  4  5  6
+ 5  6  7  8  9 10 11       3  4  5  6  7  8  9       7  8  9 10 11 12 13
+12 13 14 15 16 17 18      10 11 12 13 14 15 16      14 15 16 17 18 19 20
+19 20 21 22 23 24 25      17 18 19 20 21 22 23      21 22 23 24 25 26 27
+26 27 28 29 30            24 25 26 27 28 29 30      28 29 30
+                          31
+
+        July                     August                  September
+Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
+          1  2  3  4                         1             1  2  3  4  5
+ 5  6  7  8  9 10 11       2  3  4  5  6  7  8       6  7  8  9 10 11 12
+12 13 14 15 16 17 18       9 10 11 12 13 14 15      13 14 15 16 17 18 19
+19 20 21 22 23 24 25      16 17 18 19 20 21 22      20 21 22 23 24 25 26
+26 27 28 29 30 31         23 24 25 26 27 28 29      27 28 29 30
+                          30 31
+
+      October                   November                  December
+Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
+             1  2  3       1  2  3  4  5  6  7             1  2  3  4  5
+ 4  5  6  7  8  9 10       8  9 10 11 12 13 14       6  7  8  9 10 11 12
+11 12 13 14 15 16 17      15 16 17 18 19 20 21      13 14 15 16 17 18 19
+18 19 20 21 22 23 24      22 23 24 25 26 27 28      20 21 22 23 24 25 26
+25 26 27 28 29 30 31      29 30                     27 28 29 30 31
+"""
+
+result_2004_html = """
+<?xml version="1.0" encoding="ascii"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<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
+</head>
+<body>
+<table border="0" cellpadding="0" cellspacing="0" class="year">
+<tr><th colspan="3" class="year">2004</th></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">January</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="thu">1</td><td class="fri">2</td><td class="sat">3</td><td class="sun">4</td></tr>
+<tr><td class="mon">5</td><td class="tue">6</td><td class="wed">7</td><td class="thu">8</td><td class="fri">9</td><td class="sat">10</td><td class="sun">11</td></tr>
+<tr><td class="mon">12</td><td class="tue">13</td><td class="wed">14</td><td class="thu">15</td><td class="fri">16</td><td class="sat">17</td><td class="sun">18</td></tr>
+<tr><td class="mon">19</td><td class="tue">20</td><td class="wed">21</td><td class="thu">22</td><td class="fri">23</td><td class="sat">24</td><td class="sun">25</td></tr>
+<tr><td class="mon">26</td><td class="tue">27</td><td class="wed">28</td><td class="thu">29</td><td class="fri">30</td><td class="sat">31</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">February</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="sun">1</td></tr>
+<tr><td class="mon">2</td><td class="tue">3</td><td class="wed">4</td><td class="thu">5</td><td class="fri">6</td><td class="sat">7</td><td class="sun">8</td></tr>
+<tr><td class="mon">9</td><td class="tue">10</td><td class="wed">11</td><td class="thu">12</td><td class="fri">13</td><td class="sat">14</td><td class="sun">15</td></tr>
+<tr><td class="mon">16</td><td class="tue">17</td><td class="wed">18</td><td class="thu">19</td><td class="fri">20</td><td class="sat">21</td><td class="sun">22</td></tr>
+<tr><td class="mon">23</td><td class="tue">24</td><td class="wed">25</td><td class="thu">26</td><td class="fri">27</td><td class="sat">28</td><td class="sun">29</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">March</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="mon">1</td><td class="tue">2</td><td class="wed">3</td><td class="thu">4</td><td class="fri">5</td><td class="sat">6</td><td class="sun">7</td></tr>
+<tr><td class="mon">8</td><td class="tue">9</td><td class="wed">10</td><td class="thu">11</td><td class="fri">12</td><td class="sat">13</td><td class="sun">14</td></tr>
+<tr><td class="mon">15</td><td class="tue">16</td><td class="wed">17</td><td class="thu">18</td><td class="fri">19</td><td class="sat">20</td><td class="sun">21</td></tr>
+<tr><td class="mon">22</td><td class="tue">23</td><td class="wed">24</td><td class="thu">25</td><td class="fri">26</td><td class="sat">27</td><td class="sun">28</td></tr>
+<tr><td class="mon">29</td><td class="tue">30</td><td class="wed">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">April</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="thu">1</td><td class="fri">2</td><td class="sat">3</td><td class="sun">4</td></tr>
+<tr><td class="mon">5</td><td class="tue">6</td><td class="wed">7</td><td class="thu">8</td><td class="fri">9</td><td class="sat">10</td><td class="sun">11</td></tr>
+<tr><td class="mon">12</td><td class="tue">13</td><td class="wed">14</td><td class="thu">15</td><td class="fri">16</td><td class="sat">17</td><td class="sun">18</td></tr>
+<tr><td class="mon">19</td><td class="tue">20</td><td class="wed">21</td><td class="thu">22</td><td class="fri">23</td><td class="sat">24</td><td class="sun">25</td></tr>
+<tr><td class="mon">26</td><td class="tue">27</td><td class="wed">28</td><td class="thu">29</td><td class="fri">30</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">May</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="sat">1</td><td class="sun">2</td></tr>
+<tr><td class="mon">3</td><td class="tue">4</td><td class="wed">5</td><td class="thu">6</td><td class="fri">7</td><td class="sat">8</td><td class="sun">9</td></tr>
+<tr><td class="mon">10</td><td class="tue">11</td><td class="wed">12</td><td class="thu">13</td><td class="fri">14</td><td class="sat">15</td><td class="sun">16</td></tr>
+<tr><td class="mon">17</td><td class="tue">18</td><td class="wed">19</td><td class="thu">20</td><td class="fri">21</td><td class="sat">22</td><td class="sun">23</td></tr>
+<tr><td class="mon">24</td><td class="tue">25</td><td class="wed">26</td><td class="thu">27</td><td class="fri">28</td><td class="sat">29</td><td class="sun">30</td></tr>
+<tr><td class="mon">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">June</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="tue">1</td><td class="wed">2</td><td class="thu">3</td><td class="fri">4</td><td class="sat">5</td><td class="sun">6</td></tr>
+<tr><td class="mon">7</td><td class="tue">8</td><td class="wed">9</td><td class="thu">10</td><td class="fri">11</td><td class="sat">12</td><td class="sun">13</td></tr>
+<tr><td class="mon">14</td><td class="tue">15</td><td class="wed">16</td><td class="thu">17</td><td class="fri">18</td><td class="sat">19</td><td class="sun">20</td></tr>
+<tr><td class="mon">21</td><td class="tue">22</td><td class="wed">23</td><td class="thu">24</td><td class="fri">25</td><td class="sat">26</td><td class="sun">27</td></tr>
+<tr><td class="mon">28</td><td class="tue">29</td><td class="wed">30</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">July</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="thu">1</td><td class="fri">2</td><td class="sat">3</td><td class="sun">4</td></tr>
+<tr><td class="mon">5</td><td class="tue">6</td><td class="wed">7</td><td class="thu">8</td><td class="fri">9</td><td class="sat">10</td><td class="sun">11</td></tr>
+<tr><td class="mon">12</td><td class="tue">13</td><td class="wed">14</td><td class="thu">15</td><td class="fri">16</td><td class="sat">17</td><td class="sun">18</td></tr>
+<tr><td class="mon">19</td><td class="tue">20</td><td class="wed">21</td><td class="thu">22</td><td class="fri">23</td><td class="sat">24</td><td class="sun">25</td></tr>
+<tr><td class="mon">26</td><td class="tue">27</td><td class="wed">28</td><td class="thu">29</td><td class="fri">30</td><td class="sat">31</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">August</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="sun">1</td></tr>
+<tr><td class="mon">2</td><td class="tue">3</td><td class="wed">4</td><td class="thu">5</td><td class="fri">6</td><td class="sat">7</td><td class="sun">8</td></tr>
+<tr><td class="mon">9</td><td class="tue">10</td><td class="wed">11</td><td class="thu">12</td><td class="fri">13</td><td class="sat">14</td><td class="sun">15</td></tr>
+<tr><td class="mon">16</td><td class="tue">17</td><td class="wed">18</td><td class="thu">19</td><td class="fri">20</td><td class="sat">21</td><td class="sun">22</td></tr>
+<tr><td class="mon">23</td><td class="tue">24</td><td class="wed">25</td><td class="thu">26</td><td class="fri">27</td><td class="sat">28</td><td class="sun">29</td></tr>
+<tr><td class="mon">30</td><td class="tue">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">September</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="wed">1</td><td class="thu">2</td><td class="fri">3</td><td class="sat">4</td><td class="sun">5</td></tr>
+<tr><td class="mon">6</td><td class="tue">7</td><td class="wed">8</td><td class="thu">9</td><td class="fri">10</td><td class="sat">11</td><td class="sun">12</td></tr>
+<tr><td class="mon">13</td><td class="tue">14</td><td class="wed">15</td><td class="thu">16</td><td class="fri">17</td><td class="sat">18</td><td class="sun">19</td></tr>
+<tr><td class="mon">20</td><td class="tue">21</td><td class="wed">22</td><td class="thu">23</td><td class="fri">24</td><td class="sat">25</td><td class="sun">26</td></tr>
+<tr><td class="mon">27</td><td class="tue">28</td><td class="wed">29</td><td class="thu">30</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td></tr><tr><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">October</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="fri">1</td><td class="sat">2</td><td class="sun">3</td></tr>
+<tr><td class="mon">4</td><td class="tue">5</td><td class="wed">6</td><td class="thu">7</td><td class="fri">8</td><td class="sat">9</td><td class="sun">10</td></tr>
+<tr><td class="mon">11</td><td class="tue">12</td><td class="wed">13</td><td class="thu">14</td><td class="fri">15</td><td class="sat">16</td><td class="sun">17</td></tr>
+<tr><td class="mon">18</td><td class="tue">19</td><td class="wed">20</td><td class="thu">21</td><td class="fri">22</td><td class="sat">23</td><td class="sun">24</td></tr>
+<tr><td class="mon">25</td><td class="tue">26</td><td class="wed">27</td><td class="thu">28</td><td class="fri">29</td><td class="sat">30</td><td class="sun">31</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">November</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="mon">1</td><td class="tue">2</td><td class="wed">3</td><td class="thu">4</td><td class="fri">5</td><td class="sat">6</td><td class="sun">7</td></tr>
+<tr><td class="mon">8</td><td class="tue">9</td><td class="wed">10</td><td class="thu">11</td><td class="fri">12</td><td class="sat">13</td><td class="sun">14</td></tr>
+<tr><td class="mon">15</td><td class="tue">16</td><td class="wed">17</td><td class="thu">18</td><td class="fri">19</td><td class="sat">20</td><td class="sun">21</td></tr>
+<tr><td class="mon">22</td><td class="tue">23</td><td class="wed">24</td><td class="thu">25</td><td class="fri">26</td><td class="sat">27</td><td class="sun">28</td></tr>
+<tr><td class="mon">29</td><td class="tue">30</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td><td><table border="0" cellpadding="0" cellspacing="0" class="month">
+<tr><th colspan="7" class="month">December</th></tr>
+<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
+<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="wed">1</td><td class="thu">2</td><td class="fri">3</td><td class="sat">4</td><td class="sun">5</td></tr>
+<tr><td class="mon">6</td><td class="tue">7</td><td class="wed">8</td><td class="thu">9</td><td class="fri">10</td><td class="sat">11</td><td class="sun">12</td></tr>
+<tr><td class="mon">13</td><td class="tue">14</td><td class="wed">15</td><td class="thu">16</td><td class="fri">17</td><td class="sat">18</td><td class="sun">19</td></tr>
+<tr><td class="mon">20</td><td class="tue">21</td><td class="wed">22</td><td class="thu">23</td><td class="fri">24</td><td class="sat">25</td><td class="sun">26</td></tr>
+<tr><td class="mon">27</td><td class="tue">28</td><td class="wed">29</td><td class="thu">30</td><td class="fri">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
+</table>
+</td></tr></table></body>
+</html>
+"""
+
+
+class OutputTestCase(unittest.TestCase):
+    def normalize_calendar(self, s):
+        # Filters out locale dependant strings
+        def neitherspacenordigit(c):
+            return not c.isspace() and not c.isdigit()
+
+        lines = []
+        for line in s.splitlines(False):
+            # Drop texts, as they are locale dependent
+            if line and not filter(neitherspacenordigit, line):
+                lines.append(line)
+        return lines
+
+    def test_output(self):
+        self.assertEqual(
+            self.normalize_calendar(calendar.calendar(2004)),
+            self.normalize_calendar(result_2004_text)
+        )
+
+    def test_output_textcalendar(self):
+        self.assertEqual(
+            calendar.TextCalendar().formatyear(2004).strip(),
+            result_2004_text.strip()
+        )
+
+    def test_output_htmlcalendar(self):
+        self.assertEqual(
+            calendar.HTMLCalendar().formatyearpage(2004).strip(),
+            result_2004_html.strip()
+        )
+
+
 class CalendarTestCase(unittest.TestCase):
     def test_isleap(self):
         # Make sure that the return is right for a few years, and
@@ -72,57 +268,57 @@
     firstweekday = calendar.MONDAY
 
     def test_february(self):
-        # A 28-day february starting of monday (7+7+7+7 days)
+        # A 28-day february starting on monday (7+7+7+7 days)
         self.check_weeks(1999, 2, (7, 7, 7, 7))
 
-        # A 28-day february starting of tuesday (6+7+7+7+1 days)
+        # A 28-day february starting on tuesday (6+7+7+7+1 days)
         self.check_weeks(2005, 2, (6, 7, 7, 7, 1))
 
-        # A 28-day february starting of sunday (1+7+7+7+6 days)
+        # A 28-day february starting on sunday (1+7+7+7+6 days)
         self.check_weeks(1987, 2, (1, 7, 7, 7, 6))
 
-        # A 29-day february starting of monday (7+7+7+7+1 days)
+        # A 29-day february starting on monday (7+7+7+7+1 days)
         self.check_weeks(1988, 2, (7, 7, 7, 7, 1))
 
-        # A 29-day february starting of tuesday (6+7+7+7+2 days)
+        # A 29-day february starting on tuesday (6+7+7+7+2 days)
         self.check_weeks(1972, 2, (6, 7, 7, 7, 2))
 
-        # A 29-day february starting of sunday (1+7+7+7+7 days)
+        # A 29-day february starting on sunday (1+7+7+7+7 days)
         self.check_weeks(2004, 2, (1, 7, 7, 7, 7))
 
     def test_april(self):
-        # A 30-day april starting of monday (7+7+7+7+2 days)
+        # A 30-day april starting on monday (7+7+7+7+2 days)
         self.check_weeks(1935, 4, (7, 7, 7, 7, 2))
 
-        # A 30-day april starting of tuesday (6+7+7+7+3 days)
+        # A 30-day april starting on tuesday (6+7+7+7+3 days)
         self.check_weeks(1975, 4, (6, 7, 7, 7, 3))
 
-        # A 30-day april starting of sunday (1+7+7+7+7+1 days)
+        # A 30-day april starting on sunday (1+7+7+7+7+1 days)
         self.check_weeks(1945, 4, (1, 7, 7, 7, 7, 1))
 
-        # A 30-day april starting of saturday (2+7+7+7+7 days)
+        # A 30-day april starting on saturday (2+7+7+7+7 days)
         self.check_weeks(1995, 4, (2, 7, 7, 7, 7))
 
-        # A 30-day april starting of friday (3+7+7+7+6 days)
+        # A 30-day april starting on friday (3+7+7+7+6 days)
         self.check_weeks(1994, 4, (3, 7, 7, 7, 6))
 
     def test_december(self):
-        # A 31-day december starting of monday (7+7+7+7+3 days)
+        # A 31-day december starting on monday (7+7+7+7+3 days)
         self.check_weeks(1980, 12, (7, 7, 7, 7, 3))
 
-        # A 31-day december starting of tuesday (6+7+7+7+4 days)
+        # A 31-day december starting on tuesday (6+7+7+7+4 days)
         self.check_weeks(1987, 12, (6, 7, 7, 7, 4))
 
-        # A 31-day december starting of sunday (1+7+7+7+7+2 days)
+        # A 31-day december starting on sunday (1+7+7+7+7+2 days)
         self.check_weeks(1968, 12, (1, 7, 7, 7, 7, 2))
 
-        # A 31-day december starting of thursday (4+7+7+7+6 days)
+        # A 31-day december starting on thursday (4+7+7+7+6 days)
         self.check_weeks(1988, 12, (4, 7, 7, 7, 6))
 
-        # A 31-day december starting of friday (3+7+7+7+7 days)
+        # A 31-day december starting on friday (3+7+7+7+7 days)
         self.check_weeks(2017, 12, (3, 7, 7, 7, 7))
 
-        # A 31-day december starting of saturday (2+7+7+7+7+1 days)
+        # A 31-day december starting on saturday (2+7+7+7+7+1 days)
         self.check_weeks(2068, 12, (2, 7, 7, 7, 7, 1))
 
 
@@ -130,62 +326,63 @@
     firstweekday = calendar.SUNDAY
 
     def test_february(self):
-        # A 28-day february starting of sunday (7+7+7+7 days)
+        # A 28-day february starting on sunday (7+7+7+7 days)
         self.check_weeks(2009, 2, (7, 7, 7, 7))
 
-        # A 28-day february starting of monday (6+7+7+7+1 days)
+        # A 28-day february starting on monday (6+7+7+7+1 days)
         self.check_weeks(1999, 2, (6, 7, 7, 7, 1))
 
-        # A 28-day february starting of saturday (1+7+7+7+6 days)
+        # A 28-day february starting on saturday (1+7+7+7+6 days)
         self.check_weeks(1997, 2, (1, 7, 7, 7, 6))
 
-        # A 29-day february starting of sunday (7+7+7+7+1 days)
+        # A 29-day february starting on sunday (7+7+7+7+1 days)
         self.check_weeks(2004, 2, (7, 7, 7, 7, 1))
 
-        # A 29-day february starting of monday (6+7+7+7+2 days)
+        # A 29-day february starting on monday (6+7+7+7+2 days)
         self.check_weeks(1960, 2, (6, 7, 7, 7, 2))
 
-        # A 29-day february starting of saturday (1+7+7+7+7 days)
+        # A 29-day february starting on saturday (1+7+7+7+7 days)
         self.check_weeks(1964, 2, (1, 7, 7, 7, 7))
 
     def test_april(self):
-        # A 30-day april starting of sunday (7+7+7+7+2 days)
+        # A 30-day april starting on sunday (7+7+7+7+2 days)
         self.check_weeks(1923, 4, (7, 7, 7, 7, 2))
 
-        # A 30-day april starting of monday (6+7+7+7+3 days)
+        # A 30-day april starting on monday (6+7+7+7+3 days)
         self.check_weeks(1918, 4, (6, 7, 7, 7, 3))
 
-        # A 30-day april starting of saturday (1+7+7+7+7+1 days)
+        # A 30-day april starting on saturday (1+7+7+7+7+1 days)
         self.check_weeks(1950, 4, (1, 7, 7, 7, 7, 1))
 
-        # A 30-day april starting of friday (2+7+7+7+7 days)
+        # A 30-day april starting on friday (2+7+7+7+7 days)
         self.check_weeks(1960, 4, (2, 7, 7, 7, 7))
 
-        # A 30-day april starting of thursday (3+7+7+7+6 days)
+        # A 30-day april starting on thursday (3+7+7+7+6 days)
         self.check_weeks(1909, 4, (3, 7, 7, 7, 6))
 
     def test_december(self):
-        # A 31-day december starting of sunday (7+7+7+7+3 days)
+        # A 31-day december starting on sunday (7+7+7+7+3 days)
         self.check_weeks(2080, 12, (7, 7, 7, 7, 3))
 
-        # A 31-day december starting of monday (6+7+7+7+4 days)
+        # A 31-day december starting on monday (6+7+7+7+4 days)
         self.check_weeks(1941, 12, (6, 7, 7, 7, 4))
 
-        # A 31-day december starting of saturday (1+7+7+7+7+2 days)
+        # A 31-day december starting on saturday (1+7+7+7+7+2 days)
         self.check_weeks(1923, 12, (1, 7, 7, 7, 7, 2))
 
-        # A 31-day december starting of wednesday (4+7+7+7+6 days)
+        # A 31-day december starting on wednesday (4+7+7+7+6 days)
         self.check_weeks(1948, 12, (4, 7, 7, 7, 6))
 
-        # A 31-day december starting of thursday (3+7+7+7+7 days)
+        # A 31-day december starting on thursday (3+7+7+7+7 days)
         self.check_weeks(1927, 12, (3, 7, 7, 7, 7))
 
-        # A 31-day december starting of friday (2+7+7+7+7+1 days)
+        # A 31-day december starting on friday (2+7+7+7+7+1 days)
         self.check_weeks(1995, 12, (2, 7, 7, 7, 7, 1))
 
 
 def test_main():
     test_support.run_unittest(
+        OutputTestCase,
         CalendarTestCase,
         MondayTestCase,
         SundayTestCase
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 1dd2461..cdd84bb 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -5,44 +5,51 @@
 from test import test_support
 import _testcapi
 
-for name in dir(_testcapi):
-    if name.startswith('test_'):
-        test = getattr(_testcapi, name)
+def test_main():
+
+    for name in dir(_testcapi):
+        if name.startswith('test_'):
+            test = getattr(_testcapi, name)
+            if test_support.verbose:
+                print "internal", name
+            try:
+                test()
+            except _testcapi.error:
+                raise test_support.TestFailed, sys.exc_info()[1]
+
+    # some extra thread-state tests driven via _testcapi
+    def TestThreadState():
+        import thread
+        import time
+
         if test_support.verbose:
-            print "internal", name
-        try:
-            test()
-        except _testcapi.error:
-            raise test_support.TestFailed, sys.exc_info()[1]
+            print "auto-thread-state"
 
-# some extra thread-state tests driven via _testcapi
-def TestThreadState():
-    import thread
-    import time
+        idents = []
 
-    if test_support.verbose:
-        print "auto-thread-state"
+        def callback():
+            idents.append(thread.get_ident())
 
-    idents = []
+        _testcapi._test_thread_state(callback)
+        a = b = callback
+        time.sleep(1)
+        # Check our main thread is in the list exactly 3 times.
+        if idents.count(thread.get_ident()) != 3:
+            raise test_support.TestFailed, \
+                  "Couldn't find main thread correctly in the list"
 
-    def callback():
-        idents.append(thread.get_ident())
+    try:
+        _testcapi._test_thread_state
+        have_thread_state = True
+    except AttributeError:
+        have_thread_state = False
 
-    _testcapi._test_thread_state(callback)
-    time.sleep(1)
-    # Check our main thread is in the list exactly 3 times.
-    if idents.count(thread.get_ident()) != 3:
-        raise test_support.TestFailed, \
-              "Couldn't find main thread correctly in the list"
+    if have_thread_state:
+        TestThreadState()
+        import threading
+        t=threading.Thread(target=TestThreadState)
+        t.start()
+        t.join()
 
-try:
-    _testcapi._test_thread_state
-    have_thread_state = True
-except AttributeError:
-    have_thread_state = False
-
-if have_thread_state:
-    TestThreadState()
-    import threading
-    t=threading.Thread(target=TestThreadState)
-    t.start()
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index a4a656d..018bec6 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -10,6 +10,9 @@
         infp.close()
         data = outfp.read()
         outfp.close()
+        # try to cleanup the child so we don't appear to leak when running
+        # with regrtest -R.  This should be a no-op on Windows.
+        popen2._cleanup()
         return data
 
     def exit_code(self, cmd_line):
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 913aa91..6ea49cc 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -1,7 +1,7 @@
 from test import test_support
 import unittest
 import codecs
-import sys, StringIO
+import sys, StringIO, _testcapi
 
 class Queue(object):
     """
@@ -781,9 +781,18 @@
                 except Exception,e:
                     raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
 
-class CodecTest(unittest.TestCase):
-    def test_builtin(self):
+class IDNACodecTest(unittest.TestCase):
+    def test_builtin_decode(self):
         self.assertEquals(unicode("python.org", "idna"), u"python.org")
+        self.assertEquals(unicode("python.org.", "idna"), u"python.org.")
+        self.assertEquals(unicode("xn--pythn-mua.org", "idna"), u"pyth\xf6n.org")
+        self.assertEquals(unicode("xn--pythn-mua.org.", "idna"), u"pyth\xf6n.org.")
+
+    def test_builtin_encode(self):
+        self.assertEquals(u"python.org".encode("idna"), "python.org")
+        self.assertEquals("python.org.".encode("idna"), "python.org.")
+        self.assertEquals(u"pyth\xf6n.org".encode("idna"), "xn--pythn-mua.org")
+        self.assertEquals(u"pyth\xf6n.org.".encode("idna"), "xn--pythn-mua.org.")
 
     def test_stream(self):
         import StringIO
@@ -791,6 +800,64 @@
         r.read(3)
         self.assertEquals(r.read(), u"")
 
+    def test_incremental_decode(self):
+        self.assertEquals(
+            "".join(codecs.iterdecode("python.org", "idna")),
+            u"python.org"
+        )
+        self.assertEquals(
+            "".join(codecs.iterdecode("python.org.", "idna")),
+            u"python.org."
+        )
+        self.assertEquals(
+            "".join(codecs.iterdecode("xn--pythn-mua.org.", "idna")),
+            u"pyth\xf6n.org."
+        )
+        self.assertEquals(
+            "".join(codecs.iterdecode("xn--pythn-mua.org.", "idna")),
+            u"pyth\xf6n.org."
+        )
+
+        decoder = codecs.getincrementaldecoder("idna")()
+        self.assertEquals(decoder.decode("xn--xam", ), u"")
+        self.assertEquals(decoder.decode("ple-9ta.o", ), u"\xe4xample.")
+        self.assertEquals(decoder.decode(u"rg"), u"")
+        self.assertEquals(decoder.decode(u"", True), u"org")
+
+        decoder.reset()
+        self.assertEquals(decoder.decode("xn--xam", ), u"")
+        self.assertEquals(decoder.decode("ple-9ta.o", ), u"\xe4xample.")
+        self.assertEquals(decoder.decode("rg."), u"org.")
+        self.assertEquals(decoder.decode("", True), u"")
+
+    def test_incremental_encode(self):
+        self.assertEquals(
+            "".join(codecs.iterencode(u"python.org", "idna")),
+            "python.org"
+        )
+        self.assertEquals(
+            "".join(codecs.iterencode(u"python.org.", "idna")),
+            "python.org."
+        )
+        self.assertEquals(
+            "".join(codecs.iterencode(u"pyth\xf6n.org.", "idna")),
+            "xn--pythn-mua.org."
+        )
+        self.assertEquals(
+            "".join(codecs.iterencode(u"pyth\xf6n.org.", "idna")),
+            "xn--pythn-mua.org."
+        )
+
+        encoder = codecs.getincrementalencoder("idna")()
+        self.assertEquals(encoder.encode(u"\xe4x"), "")
+        self.assertEquals(encoder.encode(u"ample.org"), "xn--xample-9ta.")
+        self.assertEquals(encoder.encode(u"", True), "org")
+
+        encoder.reset()
+        self.assertEquals(encoder.encode(u"\xe4x"), "")
+        self.assertEquals(encoder.encode(u"ample.org."), "xn--xample-9ta.org.")
+        self.assertEquals(encoder.encode(u"", True), "")
+
 class CodecsModuleTest(unittest.TestCase):
 
     def test_decode(self):
@@ -1032,9 +1099,11 @@
                     decodedresult += reader.read()
                 self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
 
-                # check incremental decoder/encoder and iterencode()/iterdecode()
+                # check incremental decoder/encoder (fetched via the Python
+                # and C API) and iterencode()/iterdecode()
                 try:
                     encoder = codecs.getincrementalencoder(encoding)()
+                    cencoder = _testcapi.codec_incrementalencoder(encoding)
                 except LookupError: # no IncrementalEncoder
                     pass
                 else:
@@ -1042,10 +1111,24 @@
                     encodedresult = ""
                     for c in s:
                         encodedresult += encoder.encode(c)
+                    encodedresult += encoder.encode(u"", True)
                     decoder = codecs.getincrementaldecoder(encoding)()
                     decodedresult = u""
                     for c in encodedresult:
                         decodedresult += decoder.decode(c)
+                    decodedresult += decoder.decode("", True)
+                    self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
+
+                    # check C API
+                    encodedresult = ""
+                    for c in s:
+                        encodedresult += cencoder.encode(c)
+                    encodedresult += cencoder.encode(u"", True)
+                    cdecoder = _testcapi.codec_incrementaldecoder(encoding)
+                    decodedresult = u""
+                    for c in encodedresult:
+                        decodedresult += cdecoder.decode(c)
+                    decodedresult += cdecoder.decode("", True)
                     self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
 
                     # check iterencode()/iterdecode()
@@ -1142,7 +1225,7 @@
         PunycodeTest,
         UnicodeInternalTest,
         NameprepTest,
-        CodecTest,
+        IDNACodecTest,
         CodecsModuleTest,
         StreamReaderTest,
         Str2StrTest,
diff --git a/Lib/test/test_coercion.py b/Lib/test/test_coercion.py
index e12ef0d..964f161 100644
--- a/Lib/test/test_coercion.py
+++ b/Lib/test/test_coercion.py
@@ -1,6 +1,8 @@
 import copy
 import sys
 import warnings
+import unittest
+from test.test_support import run_unittest
 
 # Fake a number that implements numeric methods through __coerce__
 class CoerceNumber:
@@ -16,10 +18,19 @@
         else:
             return (self.arg, other)
 
+# New-style class version of CoerceNumber
+class CoerceTo(object):
+    def __init__(self, arg):
+        self.arg = arg
+    def __coerce__(self, other):
+        if isinstance(other, CoerceTo):
+            return self.arg, other.arg
+        else:
+            return self.arg, other
+
 
 # Fake a number that implements numeric ops through methods.
 class MethodNumber:
-
     def __init__(self,arg):
         self.arg = arg
 
@@ -50,6 +61,18 @@
     def __rtruediv__(self,other):
         return other / self.arg
 
+    def __truediv__(self,other):
+        return self.arg / other
+
+    def __rtruediv__(self,other):
+        return other / self.arg
+
+    def __floordiv__(self,other):
+        return self.arg // other
+
+    def __rfloordiv__(self,other):
+        return other // self.arg
+
     def __pow__(self,other):
         return self.arg ** other
 
@@ -66,11 +89,157 @@
         return cmp(self.arg, other)
 
 
-candidates = [ 2, 4.0, 2L, 2+0j, [1], (2,), None,
-               MethodNumber(2), CoerceNumber(2)]
+candidates = [2, 2L, 4.0, 2+0j, [1], (2,), None,
+              MethodNumber(2), CoerceNumber(2)]
 
-infix_binops = [ '+', '-', '*', '/', '**', '%' ]
+infix_binops = [ '+', '-', '*', '**', '%', '//', '/' ]
+
+TE = TypeError
+# b = both normal and augmented give same result list
+# s = single result lists for normal and augmented
+# e = equals other results
+# result lists: ['+', '-', '*', '**', '%', '//', ('classic /', 'new /')]
+#                                                ^^^^^^^^^^^^^^^^^^^^^^
+#                                               2-tuple if results differ
+#                                                 else only one value
+infix_results = {
+    # 2
+    (0,0): ('b', [4, 0, 4, 4, 0, 1, (1, 1.0)]),
+    (0,1): ('e', (0,0)),
+    (0,2): ('b', [6.0, -2.0, 8.0, 16.0, 2.0, 0.0, 0.5]),
+    (0,3): ('b', [4+0j, 0+0j, 4+0j, 4+0j, 0+0j, 1+0j, 1+0j]),
+    (0,4): ('b', [TE, TE, [1, 1], TE, TE, TE, TE]),
+    (0,5): ('b', [TE, TE, (2, 2), TE, TE, TE, TE]),
+    (0,6): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (0,7): ('e', (0,0)),
+    (0,8): ('e', (0,0)),
+
+    # 2L
+    (1,0): ('e', (0,0)),
+    (1,1): ('e', (0,1)),
+    (1,2): ('e', (0,2)),
+    (1,3): ('e', (0,3)),
+    (1,4): ('e', (0,4)),
+    (1,5): ('e', (0,5)),
+    (1,6): ('e', (0,6)),
+    (1,7): ('e', (0,7)),
+    (1,8): ('e', (0,8)),
+
+    # 4.0
+    (2,0): ('b', [6.0, 2.0, 8.0, 16.0, 0.0, 2.0, 2.0]),
+    (2,1): ('e', (2,0)),
+    (2,2): ('b', [8.0, 0.0, 16.0, 256.0, 0.0, 1.0, 1.0]),
+    (2,3): ('b', [6+0j, 2+0j, 8+0j, 16+0j, 0+0j, 2+0j, 2+0j]),
+    (2,4): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (2,5): ('e', (2,4)),
+    (2,6): ('e', (2,4)),
+    (2,7): ('e', (2,0)),
+    (2,8): ('e', (2,0)),
+
+    # (2+0j)
+    (3,0): ('b', [4+0j, 0+0j, 4+0j, 4+0j, 0+0j, 1+0j, 1+0j]),
+    (3,1): ('e', (3,0)),
+    (3,2): ('b', [6+0j, -2+0j, 8+0j, 16+0j, 2+0j, 0+0j, 0.5+0j]),
+    (3,3): ('b', [4+0j, 0+0j, 4+0j, 4+0j, 0+0j, 1+0j, 1+0j]),
+    (3,4): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (3,5): ('e', (3,4)),
+    (3,6): ('e', (3,4)),
+    (3,7): ('e', (3,0)),
+    (3,8): ('e', (3,0)),
+
+    # [1]
+    (4,0): ('b', [TE, TE, [1, 1], TE, TE, TE, TE]),
+    (4,1): ('e', (4,0)),
+    (4,2): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (4,3): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (4,4): ('b', [[1, 1], TE, TE, TE, TE, TE, TE]),
+    (4,5): ('s', [TE, TE, TE, TE, TE, TE, TE], [[1, 2], TE, TE, TE, TE, TE, TE]),
+    (4,6): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (4,7): ('e', (4,0)),
+    (4,8): ('e', (4,0)),
+
+    # (2,)
+    (5,0): ('b', [TE, TE, (2, 2), TE, TE, TE, TE]),
+    (5,1): ('e', (5,0)),
+    (5,2): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (5,3): ('e', (5,2)),
+    (5,4): ('e', (5,2)),
+    (5,5): ('b', [(2, 2), TE, TE, TE, TE, TE, TE]),
+    (5,6): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (5,7): ('e', (5,0)),
+    (5,8): ('e', (5,0)),
+
+    # None
+    (6,0): ('b', [TE, TE, TE, TE, TE, TE, TE]),
+    (6,1): ('e', (6,0)),
+    (6,2): ('e', (6,0)),
+    (6,3): ('e', (6,0)),
+    (6,4): ('e', (6,0)),
+    (6,5): ('e', (6,0)),
+    (6,6): ('e', (6,0)),
+    (6,7): ('e', (6,0)),
+    (6,8): ('e', (6,0)),
+
+    # MethodNumber(2)
+    (7,0): ('e', (0,0)),
+    (7,1): ('e', (0,1)),
+    (7,2): ('e', (0,2)),
+    (7,3): ('e', (0,3)),
+    (7,4): ('e', (0,4)),
+    (7,5): ('e', (0,5)),
+    (7,6): ('e', (0,6)),
+    (7,7): ('e', (0,7)),
+    (7,8): ('e', (0,8)),
+
+    # CoerceNumber(2)
+    (8,0): ('e', (0,0)),
+    (8,1): ('e', (0,1)),
+    (8,2): ('e', (0,2)),
+    (8,3): ('e', (0,3)),
+    (8,4): ('e', (0,4)),
+    (8,5): ('e', (0,5)),
+    (8,6): ('e', (0,6)),
+    (8,7): ('e', (0,7)),
+    (8,8): ('e', (0,8)),
+}
+
+def process_infix_results():
+    for key in sorted(infix_results):
+        val = infix_results[key]
+        if val[0] == 'e':
+            infix_results[key] = infix_results[val[1]]
+        else:
+            if val[0] == 's':
+                res = (val[1], val[2])
+            elif val[0] == 'b':
+                res = (val[1], val[1])
+            for i in range(1):
+                if isinstance(res[i][6], tuple):
+                    if 1/2 == 0:
+                        # testing with classic (floor) division
+                        res[i][6] = res[i][6][0]
+                    else:
+                        # testing with -Qnew
+                        res[i][6] = res[i][6][1]
+            infix_results[key] = res
+
+
+
+process_infix_results()
+# now infix_results has two lists of results for every pairing.
+
 prefix_binops = [ 'divmod' ]
+prefix_results = [
+    [(1,0), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1,0)],
+    [(1L,0L), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1L,0L)],
+    [(2.0,0.0), (2.0,0.0), (1.0,0.0), ((2+0j),0j), TE, TE, TE, TE, (2.0,0.0)],
+    [((1+0j),0j), ((1+0j),0j), (0j,(2+0j)), ((1+0j),0j), TE, TE, TE, TE, ((1+0j),0j)],
+    [TE, TE, TE, TE, TE, TE, TE, TE, TE],
+    [TE, TE, TE, TE, TE, TE, TE, TE, TE],
+    [TE, TE, TE, TE, TE, TE, TE, TE, TE],
+    [TE, TE, TE, TE, TE, TE, TE, TE, TE],
+    [(1,0), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1,0)]
+]
 
 def format_float(value):
     if abs(value) < 0.01:
@@ -87,83 +256,74 @@
         return format_float(value)
     return str(value)
 
-def do_infix_binops():
-    for a in candidates:
-        for b in candidates:
-            for op in infix_binops:
-                print '%s %s %s' % (a, op, b),
-                try:
-                    x = eval('a %s b' % op)
-                except:
-                    error = sys.exc_info()[:2]
-                    print '... %s.%s' % (error[0].__module__, error[0].__name__)
-                else:
-                    print '=', format_result(x)
-                try:
-                    z = copy.copy(a)
-                except copy.Error:
-                    z = a # assume it has no inplace ops
-                print '%s %s= %s' % (a, op, b),
-                try:
-                    exec('z %s= b' % op)
-                except:
-                    error = sys.exc_info()[:2]
-                    print '... %s.%s' % (error[0].__module__, error[0].__name__)
-                else:
-                    print '=>', format_result(z)
+class CoercionTest(unittest.TestCase):
+    def test_infix_binops(self):
+        for ia, a in enumerate(candidates):
+            for ib, b in enumerate(candidates):
+                results = infix_results[(ia, ib)]
+                for op, res, ires in zip(infix_binops, results[0], results[1]):
+                    if res is TE:
+                        self.assertRaises(TypeError, eval,
+                                          'a %s b' % op, {'a': a, 'b': b})
+                    else:
+                        self.assertEquals(format_result(res),
+                                          format_result(eval('a %s b' % op)),
+                                          '%s %s %s == %s failed' % (a, op, b, res))
+                    try:
+                        z = copy.copy(a)
+                    except copy.Error:
+                        z = a # assume it has no inplace ops
+                    if ires is TE:
+                        try:
+                            exec 'z %s= b' % op
+                        except TypeError:
+                            pass
+                        else:
+                            self.fail("TypeError not raised")
+                    else:
+                        exec('z %s= b' % op)
+                        self.assertEquals(ires, z)
 
-def do_prefix_binops():
-    for a in candidates:
-        for b in candidates:
-            for op in prefix_binops:
-                print '%s(%s, %s)' % (op, a, b),
-                try:
-                    x = eval('%s(a, b)' % op)
-                except:
-                    error = sys.exc_info()[:2]
-                    print '... %s.%s' % (error[0].__module__, error[0].__name__)
-                else:
-                    print '=', format_result(x)
+    def test_prefix_binops(self):
+        for ia, a in enumerate(candidates):
+            for ib, b in enumerate(candidates):
+                for op in prefix_binops:
+                    res = prefix_results[ia][ib]
+                    if res is TE:
+                        self.assertRaises(TypeError, eval,
+                                          '%s(a, b)' % op, {'a': a, 'b': b})
+                    else:
+                        self.assertEquals(format_result(res),
+                                          format_result(eval('%s(a, b)' % op)),
+                                          '%s(%s, %s) == %s failed' % (op, a, b, res))
 
-# New-style class version of CoerceNumber
-class CoerceTo(object):
-    def __init__(self, arg):
-        self.arg = arg
-    def __coerce__(self, other):
-        if isinstance(other, CoerceTo):
-            return self.arg, other.arg
-        else:
-            return self.arg, other
+    def test_cmptypes(self):
+        # Built-in tp_compare slots expect their arguments to have the
+        # same type, but a user-defined __coerce__ doesn't have to obey.
+        # SF #980352
+        evil_coercer = CoerceTo(42)
+        # Make sure these don't crash any more
+        self.assertNotEquals(cmp(u'fish', evil_coercer), 0)
+        self.assertNotEquals(cmp(slice(1), evil_coercer), 0)
+        # ...but that this still works
+        class WackyComparer(object):
+            def __cmp__(slf, other):
+                self.assert_(other == 42, 'expected evil_coercer, got %r' % other)
+                return 0
+        self.assertEquals(cmp(WackyComparer(), evil_coercer), 0)
+        # ...and classic classes too, since that code path is a little different
+        class ClassicWackyComparer:
+            def __cmp__(slf, other):
+                self.assert_(other == 42, 'expected evil_coercer, got %r' % other)
+                return 0
+        self.assertEquals(cmp(ClassicWackyComparer(), evil_coercer), 0)
 
-def assert_(expr, msg=None):
-    if not expr:
-        raise AssertionError, msg
+def test_main():
+    warnings.filterwarnings("ignore",
+                            r'complex divmod\(\), // and % are deprecated',
+                            DeprecationWarning,
+                            r'test.test_coercion$')
+    run_unittest(CoercionTest)
 
-def do_cmptypes():
-    # Built-in tp_compare slots expect their arguments to have the
-    # same type, but a user-defined __coerce__ doesn't have to obey.
-    # SF #980352
-    evil_coercer = CoerceTo(42)
-    # Make sure these don't crash any more
-    assert_(cmp(u'fish', evil_coercer) != 0)
-    assert_(cmp(slice(1), evil_coercer) != 0)
-    # ...but that this still works
-    class WackyComparer(object):
-        def __cmp__(self, other):
-            assert_(other == 42, 'expected evil_coercer, got %r' % other)
-            return 0
-    assert_(cmp(WackyComparer(), evil_coercer) == 0)
-    # ...and classic classes too, since that code path is a little different
-    class ClassicWackyComparer:
-        def __cmp__(self, other):
-            assert_(other == 42, 'expected evil_coercer, got %r' % other)
-            return 0
-    assert_(cmp(ClassicWackyComparer(), evil_coercer) == 0)
-
-warnings.filterwarnings("ignore",
-                        r'complex divmod\(\), // and % are deprecated',
-                        DeprecationWarning,
-                        r'test.test_coercion$')
-do_infix_binops()
-do_prefix_binops()
-do_cmptypes()
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_compare.py b/Lib/test/test_compare.py
index 6899926..2fde614 100644
--- a/Lib/test/test_compare.py
+++ b/Lib/test/test_compare.py
@@ -1,4 +1,6 @@
 import sys
+import unittest
+from test import test_support
 
 class Empty:
     def __repr__(self):
@@ -27,28 +29,31 @@
     def __cmp__(self, other):
         return cmp(self.arg, other)
 
+class ComparisonTest(unittest.TestCase):
+    set1 = [2, 2.0, 2L, 2+0j, Coerce(2), Cmp(2.0)]
+    set2 = [[1], (3,), None, Empty()]
+    candidates = set1 + set2
 
-candidates = [2, 2.0, 2L, 2+0j, [1], (3,), None, Empty(), Coerce(2), Cmp(2.0)]
-
-def test():
-    for a in candidates:
-        for b in candidates:
-            try:
-                x = a == b
-            except:
-                print 'cmp(%s, %s) => %s' % (a, b, sys.exc_info()[0])
-            else:
-                if x:
-                    print "%s == %s" % (a, b)
+    def test_comparisons(self):
+        for a in self.candidates:
+            for b in self.candidates:
+                if ((a in self.set1) and (b in self.set1)) or a is b:
+                    self.assertEqual(a, b)
                 else:
-                    print "%s != %s" % (a, b)
-    # Ensure default comparison compares id() of args
-    L = []
-    for i in range(10):
-        L.insert(len(L)//2, Empty())
-    for a in L:
-        for b in L:
-            if cmp(a, b) != cmp(id(a), id(b)):
-                print "ERROR:", cmp(a, b), cmp(id(a), id(b)), id(a), id(b)
+                    self.assertNotEqual(a, b)
 
-test()
+    def test_id_comparisons(self):
+        # Ensure default comparison compares id() of args
+        L = []
+        for i in range(10):
+            L.insert(len(L)//2, Empty())
+        for a in L:
+            for b in L:
+                self.assertEqual(cmp(a, b), cmp(id(a), id(b)),
+                                 'a=%r, b=%r' % (a, b))
+
+def test_main():
+    test_support.run_unittest(ComparisonTest)
+
+if __name__ == '__main__':
+    test_main()
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 1d47f91..72c4f7e 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -284,6 +284,10 @@
         f1, f2 = f()
         self.assertNotEqual(id(f1.func_code), id(f2.func_code))
 
+    def test_unicode_encoding(self):
+        code = u"# -*- coding: utf-8 -*-\npass\n"
+        self.assertRaises(SyntaxError, compile, code, "tmp", "exec")
+
     def test_subscripts(self):
         # SF bug 1448804
         # Class to make testing subscript results easy
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
index 5e7b15c..a59d6aa 100644
--- a/Lib/test/test_compiler.py
+++ b/Lib/test/test_compiler.py
@@ -1,10 +1,12 @@
 import compiler
 from compiler.ast import flatten
-import os
+import os, sys, time, unittest
 import test.test_support
-import unittest
 from random import random
 
+# How much time in seconds can pass before we print a 'Still working' message.
+_PRINT_WORKING_MSG_INTERVAL = 5 * 60
+
 class CompilerTest(unittest.TestCase):
 
     def testCompileLibrary(self):
@@ -13,11 +15,18 @@
         # that any of the code is correct, merely the compiler is able
         # to generate some kind of code for it.
 
+        next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
         libdir = os.path.dirname(unittest.__file__)
         testdir = os.path.dirname(test.test_support.__file__)
 
         for dir in [libdir, testdir]:
             for basename in os.listdir(dir):
+                # Print still working message since this test can be really slow
+                if next_time <= time.time():
+                    next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
+                    print >>sys.__stdout__, \
+                       '  testCompileLibrary still working, be patient...'
+
                 if not basename.endswith(".py"):
                     continue
                 if not TEST_ALL and random() < 0.98:
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index f8db88c..97470c7 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -2,12 +2,14 @@
 
 from __future__ import with_statement
 
+import sys
 import os
 import decimal
 import tempfile
 import unittest
 import threading
 from contextlib import *  # Tests __all__
+from test.test_support import run_suite
 
 class ContextManagerTestCase(unittest.TestCase):
 
@@ -45,6 +47,28 @@
             self.fail("Expected ZeroDivisionError")
         self.assertEqual(state, [1, 42, 999])
 
+    def test_contextmanager_no_reraise(self):
+        @contextmanager
+        def whee():
+            yield
+        ctx = whee().__context__()
+        ctx.__enter__()
+        # Calling __exit__ should not result in an exception
+        self.failIf(ctx.__exit__(TypeError, TypeError("foo"), None))
+
+    def test_contextmanager_trap_yield_after_throw(self):
+        @contextmanager
+        def whoo():
+            try:
+                yield
+            except:
+                yield
+        ctx = whoo().__context__()
+        ctx.__enter__()
+        self.assertRaises(
+            RuntimeError, ctx.__exit__, TypeError, TypeError("foo"), None
+        )
+
     def test_contextmanager_except(self):
         state = []
         @contextmanager
@@ -62,6 +86,21 @@
             raise ZeroDivisionError(999)
         self.assertEqual(state, [1, 42, 999])
 
+    def test_contextmanager_attribs(self):
+        def attribs(**kw):
+            def decorate(func):
+                for k,v in kw.items():
+                    setattr(func,k,v)
+                return func
+            return decorate
+        @contextmanager
+        @attribs(foo='bar')
+        def baz(spam):
+            """Whee!"""
+        self.assertEqual(baz.__name__,'baz')
+        self.assertEqual(baz.foo, 'bar')
+        self.assertEqual(baz.__doc__, "Whee!")
+
 class NestedTestCase(unittest.TestCase):
 
     # XXX This needs more work
@@ -274,21 +313,31 @@
 
     def testBasic(self):
         ctx = decimal.getcontext()
-        ctx.prec = save_prec = decimal.ExtendedContext.prec + 5
-        with decimal.ExtendedContext:
-            self.assertEqual(decimal.getcontext().prec,
-                             decimal.ExtendedContext.prec)
-        self.assertEqual(decimal.getcontext().prec, save_prec)
+        orig_context = ctx.copy()
         try:
+            ctx.prec = save_prec = decimal.ExtendedContext.prec + 5
             with decimal.ExtendedContext:
                 self.assertEqual(decimal.getcontext().prec,
                                  decimal.ExtendedContext.prec)
-                1/0
-        except ZeroDivisionError:
             self.assertEqual(decimal.getcontext().prec, save_prec)
-        else:
-            self.fail("Didn't raise ZeroDivisionError")
+            try:
+                with decimal.ExtendedContext:
+                    self.assertEqual(decimal.getcontext().prec,
+                                     decimal.ExtendedContext.prec)
+                    1/0
+            except ZeroDivisionError:
+                self.assertEqual(decimal.getcontext().prec, save_prec)
+            else:
+                self.fail("Didn't raise ZeroDivisionError")
+        finally:
+            decimal.setcontext(orig_context)
 
 
+# This is needed to make the test actually run under regrtest.py!
+def test_main():
+    run_suite(
+        unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__])
+    )
+
 if __name__ == "__main__":
-    unittest.main()
+    test_main()
diff --git a/Lib/test/test_copy_reg.py b/Lib/test/test_copy_reg.py
index c41946a..c3d3964 100644
--- a/Lib/test/test_copy_reg.py
+++ b/Lib/test/test_copy_reg.py
@@ -8,6 +8,22 @@
     pass
 
 
+class WithoutSlots(object):
+    pass
+
+class WithWeakref(object):
+    __slots__ = ('__weakref__',)
+
+class WithPrivate(object):
+    __slots__ = ('__spam',)
+
+class WithSingleString(object):
+    __slots__ = 'spam'
+
+class WithInherited(WithSingleString):
+    __slots__ = ('eggs',)
+
+
 class CopyRegTestCase(unittest.TestCase):
 
     def test_class(self):
@@ -84,6 +100,19 @@
             self.assertRaises(ValueError, copy_reg.add_extension,
                               mod, func, code)
 
+    def test_slotnames(self):
+        self.assertEquals(copy_reg._slotnames(WithoutSlots), [])
+        self.assertEquals(copy_reg._slotnames(WithWeakref), [])
+        expected = ['_WithPrivate__spam']
+        self.assertEquals(copy_reg._slotnames(WithPrivate), expected)
+        self.assertEquals(copy_reg._slotnames(WithSingleString), ['spam'])
+        expected = ['eggs', 'spam']
+        expected.sort()
+        result = copy_reg._slotnames(WithInherited)
+        result.sort()
+        self.assertEquals(result, expected)
+
+
 def test_main():
     test_support.run_unittest(CopyRegTestCase)
 
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index a4a45a7..dc2f20b 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -24,6 +24,9 @@
 if not term or term == 'unknown':
     raise TestSkipped, "$TERM=%r, calling initscr() may cause exit" % term
 
+if sys.platform == "cygwin":
+    raise TestSkipped("cygwin's curses mostly just hangs")
+
 def window_funcs(stdscr):
     "Test the methods of windows"
     win = curses.newwin(10,10)
@@ -201,11 +204,13 @@
         curses.has_key(13)
 
     if hasattr(curses, 'getmouse'):
-        curses.mousemask(curses.BUTTON1_PRESSED)
-        curses.mouseinterval(10)
-        # just verify these don't cause errors
-        m = curses.getmouse()
-        curses.ungetmouse(*m)
+        (availmask, oldmask) = curses.mousemask(curses.BUTTON1_PRESSED)
+        # availmask indicates that mouse stuff not available.
+        if availmask != 0:
+            curses.mouseinterval(10)
+            # just verify these don't cause errors
+            m = curses.getmouse()
+            curses.ungetmouse(*m)
 
 def unit_tests():
     from curses import ascii
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index 27f42c6..2528b4a 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -1168,6 +1168,17 @@
         self.assertEqual(dt2 - dt1, us)
         self.assert_(dt1 < dt2)
 
+    def test_strftime_with_bad_tzname_replace(self):
+        # verify ok if tzinfo.tzname().replace() returns a non-string
+        class MyTzInfo(FixedOffset):
+            def tzname(self, dt):
+                class MyStr(str):
+                    def replace(self, *args):
+                        return None
+                return MyStr('name')
+        t = self.theclass(2005, 3, 2, 0, 0, 0, 0, MyTzInfo(3, 'name'))
+        self.assertRaises(TypeError, t.strftime, '%Z')
+
     def test_bad_constructor_arguments(self):
         # bad years
         self.theclass(MINYEAR, 1, 1)  # no exception
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 1d33ec4..341ad6d 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -29,7 +29,8 @@
 import os, sys
 import pickle, copy
 from decimal import *
-from test.test_support import TestSkipped, run_unittest, run_doctest, is_resource_enabled
+from test.test_support import (TestSkipped, run_unittest, run_doctest,
+                               is_resource_enabled)
 import random
 try:
     import threading
@@ -39,12 +40,15 @@
 # Useful Test Constant
 Signals = getcontext().flags.keys()
 
-# Tests are built around these assumed context defaults
-DefaultContext.prec=9
-DefaultContext.rounding=ROUND_HALF_EVEN
-DefaultContext.traps=dict.fromkeys(Signals, 0)
-setcontext(DefaultContext)
-
+# Tests are built around these assumed context defaults.
+# test_main() restores the original context.
+def init():
+    global ORIGINAL_CONTEXT
+    ORIGINAL_CONTEXT = getcontext().copy()
+    DefaultContext.prec = 9
+    DefaultContext.rounding = ROUND_HALF_EVEN
+    DefaultContext.traps = dict.fromkeys(Signals, 0)
+    setcontext(DefaultContext)
 
 TESTDATADIR = 'decimaltestdata'
 if __name__ == '__main__':
@@ -503,16 +507,17 @@
         self.assertEqual(eval('Decimal(10) != E()'), 'ne 10')
 
         # insert operator methods and then exercise them
-        for sym, lop, rop in (
-                ('+', '__add__', '__radd__'),
-                ('-', '__sub__', '__rsub__'),
-                ('*', '__mul__', '__rmul__'),
-                ('/', '__truediv__', '__rtruediv__'),
-                ('%', '__mod__', '__rmod__'),
-                ('//', '__floordiv__', '__rfloordiv__'),
-                ('**', '__pow__', '__rpow__'),
-            ):
+        oplist = [
+            ('+', '__add__', '__radd__'),
+            ('-', '__sub__', '__rsub__'),
+            ('*', '__mul__', '__rmul__'),
+            ('/', '__truediv__', '__rtruediv__')
+            ('%', '__mod__', '__rmod__'),
+            ('//', '__floordiv__', '__rfloordiv__'),
+            ('**', '__pow__', '__rpow__')
+        ]
 
+        for sym, lop, rop in oplist:
             setattr(E, lop, lambda self, other: 'str' + lop + str(other))
             setattr(E, rop, lambda self, other: str(other) + rop + 'str')
             self.assertEqual(eval('E()' + sym + 'Decimal(10)'),
@@ -1059,6 +1064,7 @@
     is enabled in regrtest.py
     """
 
+    init()
     global TEST_ALL
     TEST_ALL = arith or is_resource_enabled('decimal')
 
@@ -1073,10 +1079,12 @@
         DecimalTest,
     ]
 
-    run_unittest(*test_classes)
-    import decimal as DecimalModule
-    run_doctest(DecimalModule, verbose)
-
+    try:
+        run_unittest(*test_classes)
+        import decimal as DecimalModule
+        run_doctest(DecimalModule, verbose)
+    finally:
+        setcontext(ORIGINAL_CONTEXT)
 
 if __name__ == '__main__':
     # Calling with no arguments runs all tests.
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 185edb3..89cebb0 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1638,7 +1638,9 @@
     c1 = C()
     c2 = C()
     verify(not not c1)
-    vereq(hash(c1), id(c1))
+    verify(id(c1) != id(c2))
+    hash(c1)
+    hash(c2)
     vereq(cmp(c1, c2), cmp(id(c1), id(c2)))
     vereq(c1, c1)
     verify(c1 != c2)
@@ -1660,7 +1662,9 @@
     d1 = D()
     d2 = D()
     verify(not not d1)
-    vereq(hash(d1), id(d1))
+    verify(id(d1) != id(d2))
+    hash(d1)
+    hash(d2)
     vereq(cmp(d1, d2), cmp(id(d1), id(d2)))
     vereq(d1, d1)
     verify(d1 != d2)
@@ -2914,7 +2918,7 @@
     class D(B, C):
         pass
     d = D()
-    vereq(hash(d), id(d))
+    orig_hash = hash(d) # related to id(d) in platform-dependent ways
     A.__hash__ = lambda self: 42
     vereq(hash(d), 42)
     C.__hash__ = lambda self: 314
@@ -2930,7 +2934,7 @@
     del C.__hash__
     vereq(hash(d), 42)
     del A.__hash__
-    vereq(hash(d), id(d))
+    vereq(hash(d), orig_hash)
     d.foo = 42
     d.bar = 42
     vereq(d.foo, 42)
diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py
index 52feef0..83fad15 100644
--- a/Lib/test/test_difflib.py
+++ b/Lib/test/test_difflib.py
@@ -152,6 +152,10 @@
         difflib.SequenceMatcher(None, old, new).get_opcodes()
 
 
-Doctests = doctest.DocTestSuite(difflib)
+def test_main():
+    difflib.HtmlDiff._default_prefix = 0
+    Doctests = doctest.DocTestSuite(difflib)
+    run_unittest(TestSFpatches, TestSFbugs, Doctests)
 
-run_unittest(TestSFpatches, TestSFbugs, Doctests)
+if __name__ == '__main__':
+    test_main()
diff --git a/Lib/test/test_dl.py b/Lib/test/test_dl.py
index d1f73b2..b70a4cf 100755
--- a/Lib/test/test_dl.py
+++ b/Lib/test/test_dl.py
@@ -10,6 +10,7 @@
     ('/usr/lib/libc.so', 'getpid'),
     ('/lib/libc.so.6', 'getpid'),
     ('/usr/bin/cygwin1.dll', 'getpid'),
+    ('/usr/lib/libc.dylib', 'getpid'),
     ]
 
 for s, func in sharedlibs:
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 1f89ac2..b17607d 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -604,8 +604,8 @@
     ...     >>> for x in range(10):
     ...     ...     print x,
     ...     0 1 2 3 4 5 6 7 8 9
-    ...     >>> x/2
-    ...     6.0
+    ...     >>> x//2
+    ...     6
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
     >>> [e.lineno for e in test.examples]
@@ -679,8 +679,8 @@
     ...     >>> x = 12
     ...     >>> print x
     ...     12
-    ...     >>> x/2
-    ...     6.0
+    ...     >>> x//2
+    ...     6
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
 
@@ -700,8 +700,8 @@
     ...     >>> x = 12
     ...     >>> print x
     ...     14
-    ...     >>> x/2
-    ...     6.0
+    ...     >>> x//2
+    ...     6
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
     >>> doctest.DocTestRunner(verbose=True).run(test)
@@ -723,9 +723,9 @@
     Got:
         12
     Trying:
-        x/2
+        x//2
     Expecting:
-        6.0
+        6
     ok
     (1, 3)
 """
@@ -738,8 +738,8 @@
     ...     >>> x = 12
     ...     >>> print x
     ...     12
-    ...     >>> x/2
-    ...     6.0
+    ...     >>> x//2
+    ...     6
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
 
@@ -754,9 +754,9 @@
         12
     ok
     Trying:
-        x/2
+        x//2
     Expecting:
-        6.0
+        6
     ok
     (0, 3)
 
@@ -784,9 +784,9 @@
         12
     ok
     Trying:
-        x/2
+        x//2
     Expecting:
-        6.0
+        6
     ok
     (0, 3)
 
@@ -806,9 +806,9 @@
     >>> def f(x):
     ...     '''
     ...     >>> x = 12
-    ...     >>> print x/0
+    ...     >>> print x//0
     ...     Traceback (most recent call last):
-    ...     ZeroDivisionError: float division
+    ...     ZeroDivisionError: integer division or modulo by zero
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
     >>> doctest.DocTestRunner(verbose=False).run(test)
@@ -822,10 +822,10 @@
     >>> def f(x):
     ...     '''
     ...     >>> x = 12
-    ...     >>> print 'pre-exception output', x/0
+    ...     >>> print 'pre-exception output', x//0
     ...     pre-exception output
     ...     Traceback (most recent call last):
-    ...     ZeroDivisionError: float division
+    ...     ZeroDivisionError: integer division or modulo by zero
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
     >>> doctest.DocTestRunner(verbose=False).run(test)
@@ -833,10 +833,10 @@
     **********************************************************************
     File ..., line 4, in f
     Failed example:
-        print 'pre-exception output', x/0
+        print 'pre-exception output', x//0
     Exception raised:
         ...
-        ZeroDivisionError: float division
+        ZeroDivisionError: integer division or modulo by zero
     (1, 2)
 
 Exception messages may contain newlines:
@@ -920,7 +920,7 @@
 
     >>> def f(x):
     ...     r'''
-    ...     >>> 1/0
+    ...     >>> 1//0
     ...     0
     ...     '''
     >>> test = doctest.DocTestFinder().find(f)[0]
@@ -929,11 +929,11 @@
     **********************************************************************
     File ..., line 3, in f
     Failed example:
-        1/0
+        1//0
     Exception raised:
         Traceback (most recent call last):
         ...
-        ZeroDivisionError: float division
+        ZeroDivisionError: integer division or modulo by zero
     (1, 1)
 """
     def optionflags(): r"""
diff --git a/Lib/test/test_email_renamed.py b/Lib/test/test_email_renamed.py
new file mode 100644
index 0000000..c3af598
--- /dev/null
+++ b/Lib/test/test_email_renamed.py
@@ -0,0 +1,13 @@
+# Copyright (C) 2001-2006 Python Software Foundation
+# email package unit tests
+
+import unittest
+# The specific tests now live in Lib/email/test
+from email.test.test_email_renamed import suite
+from test.test_support import run_suite
+
+def test_main():
+    run_suite(suite())
+
+if __name__ == '__main__':
+    test_main()
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index fd5670a..ab3da86 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -100,12 +100,18 @@
     print "writelines accepted sequence of non-string objects"
 f.close()
 
-try:
-    sys.stdin.seek(-1)
-except IOError:
-    pass
+# This causes the interpreter to exit on OSF1 v5.1.
+if sys.platform != 'osf1V5':
+    try:
+        sys.stdin.seek(-1)
+    except IOError:
+        pass
+    else:
+        print "should not be able to seek on sys.stdin"
 else:
-    print "should not be able to seek on sys.stdin"
+    print >>sys.__stdout__, (
+        '  Skipping sys.stdin.seek(-1), it may crash the interpreter.'
+        ' Test manually.')
 
 try:
     sys.stdin.truncate()
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index f3a7841..301769e 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -162,7 +162,10 @@
     print "15. Unicode filenames"
 try:
     t1 = writeTmp(1, ["A\nB"])
-    fi = FileInput(files=unicode(t1, sys.getfilesystemencoding()))
+    encoding = sys.getfilesystemencoding()
+    if encoding is None:
+        encoding = 'ascii'
+    fi = FileInput(files=unicode(t1, encoding))
     lines = list(fi)
     verify(lines == ["A\n", "B"])
 finally:
diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py
index aca7a84..cba5fc7 100644
--- a/Lib/test/test_fork1.py
+++ b/Lib/test/test_fork1.py
@@ -1,75 +1,23 @@
 """This test checks for correct fork() behavior.
-
-We want fork1() semantics -- only the forking thread survives in the
-child after a fork().
-
-On some systems (e.g. Solaris without posix threads) we find that all
-active threads survive in the child after a fork(); this is an error.
-
-While BeOS doesn't officially support fork and native threading in
-the same application, the present example should work just fine.  DC
 """
 
-import os, sys, time, thread
-from test.test_support import verify, verbose, TestSkipped
+import os
+from test.fork_wait import ForkWait
+from test.test_support import TestSkipped, run_unittest
 
 try:
     os.fork
 except AttributeError:
     raise TestSkipped, "os.fork not defined -- skipping test_fork1"
 
-LONGSLEEP = 2
-
-SHORTSLEEP = 0.5
-
-NUM_THREADS = 4
-
-alive = {}
-
-stop = 0
-
-def f(id):
-    while not stop:
-        alive[id] = os.getpid()
-        try:
-            time.sleep(SHORTSLEEP)
-        except IOError:
-            pass
-
-def main():
-    for i in range(NUM_THREADS):
-        thread.start_new(f, (i,))
-
-    time.sleep(LONGSLEEP)
-
-    a = alive.keys()
-    a.sort()
-    verify(a == range(NUM_THREADS))
-
-    prefork_lives = alive.copy()
-
-    if sys.platform in ['unixware7']:
-        cpid = os.fork1()
-    else:
-        cpid = os.fork()
-
-    if cpid == 0:
-        # Child
-        time.sleep(LONGSLEEP)
-        n = 0
-        for key in alive.keys():
-            if alive[key] != prefork_lives[key]:
-                n = n+1
-        os._exit(n)
-    else:
-        # Parent
+class ForkTest(ForkWait):
+    def wait_impl(self, cpid):
         spid, status = os.waitpid(cpid, 0)
-        verify(spid == cpid)
-        verify(status == 0,
-                "cause = %d, exit = %d" % (status&0xff, status>>8) )
-        global stop
-        # Tell threads to die
-        stop = 1
-        time.sleep(2*SHORTSLEEP) # Wait for threads to die
+        self.assertEqual(spid, cpid)
+        self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
 
-main()
+def test_main():
+    run_unittest(ForkTest)
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 4be1b4c..a60a768 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -421,7 +421,6 @@
 ...         self.name = name
 ...         self.parent = None
 ...         self.generator = self.generate()
-...         self.close = self.generator.close
 ...
 ...     def generate(self):
 ...         while not self.parent:
@@ -484,8 +483,6 @@
 merged A into G
 A->G B->G C->G D->G E->G F->G G->G H->G I->G J->G K->G L->G M->G
 
->>> for s in sets: s.close()    # break cycles
-
 """
 # Emacs turd '
 
@@ -593,7 +590,6 @@
 ...     def __init__(self, g):
 ...         self.sofar = []
 ...         self.fetch = g.next
-...         self.close = g.close
 ...
 ...     def __getitem__(self, i):
 ...         sofar, fetch = self.sofar, self.fetch
@@ -624,8 +620,6 @@
 [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384]
 [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675]
 
->>> m235.close()
-
 Ye olde Fibonacci generator, LazyList style.
 
 >>> def fibgen(a, b):
@@ -648,7 +642,6 @@
 >>> fib = LazyList(fibgen(1, 2))
 >>> firstn(iter(fib), 17)
 [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584]
->>> fib.close()
 
 
 Running after your tail with itertools.tee (new in version 2.4)
@@ -685,7 +678,8 @@
 ...                        merge(times(3, m3),
 ...                              times(5, m5))):
 ...             yield n
-...     m2, m3, m5, mRes = tee(_m235(), 4)
+...     m1 = _m235()
+...     m2, m3, m5, mRes = tee(m1, 4)
 ...     return mRes
 
 >>> it = m235()
@@ -702,10 +696,9 @@
 iterators, whereupon it is deleted. You can therefore print the hamming
 sequence during hours without increasing memory usage, or very little.
 
-The beauty of it is that recursive running after their tail FP algorithms
+The beauty of it is that recursive running-after-their-tail FP algorithms
 are quite straightforwardly expressed with this Python idiom.
 
-
 Ye olde Fibonacci generator, tee style.
 
 >>> def fib():
@@ -721,7 +714,8 @@
 ...         for res in _isum(fibHead, fibTail):
 ...             yield res
 ...
-...     fibHead, fibTail, fibRes = tee(_fib(), 3)
+...     realfib = _fib()
+...     fibHead, fibTail, fibRes = tee(realfib, 3)
 ...     return fibRes
 
 >>> firstn(fib(), 17)
@@ -1545,6 +1539,9 @@
 >>> g.throw(ValueError, TypeError(1))  # mismatched type, rewrapped
 caught ValueError (1)
 
+>>> g.throw(ValueError, ValueError(1), None)   # explicit None traceback
+caught ValueError (1)
+
 >>> g.throw(ValueError(1), "foo")       # bad args
 Traceback (most recent call last):
   ...
@@ -1592,8 +1589,7 @@
 >>> f().throw("abc")     # throw on just-opened generator
 Traceback (most recent call last):
   ...
-TypeError: exceptions must be classes, or instances, not str
-
+abc
 
 Now let's try closing a generator:
 
@@ -1711,6 +1707,81 @@
 
 """
 
+refleaks_tests = """
+Prior to adding cycle-GC support to itertools.tee, this code would leak
+references. We add it to the standard suite so the routine refleak-tests
+would trigger if it starts being uncleanable again.
+
+>>> import itertools
+>>> def leak():
+...     class gen:
+...         def __iter__(self):
+...             return self
+...         def next(self):
+...             return self.item
+...     g = gen()
+...     head, tail = itertools.tee(g)
+...     g.item = head
+...     return head
+>>> it = leak()
+
+Make sure to also test the involvement of the tee-internal teedataobject,
+which stores returned items.
+
+>>> item = it.next()
+
+
+
+This test leaked at one point due to generator finalization/destruction.
+It was copied from Lib/test/leakers/test_generator_cycle.py before the file
+was removed.
+
+>>> def leak():
+...    def gen():
+...        while True:
+...            yield g
+...    g = gen()
+
+>>> leak()
+
+
+
+This test isn't really generator related, but rather exception-in-cleanup
+related. The coroutine tests (above) just happen to cause an exception in
+the generator's __del__ (tp_del) method. We can also test for this
+explicitly, without generators. We do have to redirect stderr to avoid
+printing warnings and to doublecheck that we actually tested what we wanted
+to test.
+
+>>> import sys, StringIO
+>>> old = sys.stderr
+>>> try:
+...     sys.stderr = StringIO.StringIO()
+...     class Leaker:
+...         def __del__(self):
+...             raise RuntimeError
+...
+...     l = Leaker()
+...     del l
+...     err = sys.stderr.getvalue().strip()
+...     err.startswith(
+...         "Exception exceptions.RuntimeError: RuntimeError() in <"
+...     )
+...     err.endswith("> ignored")
+...     len(err.splitlines())
+... finally:
+...     sys.stderr = old
+True
+True
+1
+
+
+
+These refleak tests should perhaps be in a testfile of their own,
+test_generators just happened to be the test that drew these out.
+
+"""
+
 __test__ = {"tut":      tutorial_tests,
             "pep":      pep_tests,
             "email":    email_tests,
@@ -1719,6 +1790,7 @@
             "conjoin":  conjoin_tests,
             "weakref":  weakref_tests,
             "coroutine":  coroutine_tests,
+            "refleaks": refleaks_tests,
             }
 
 # Magic test name that regrtest.py invokes *after* importing this module.
diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py
index 1556604..e414757 100644
--- a/Lib/test/test_genexps.py
+++ b/Lib/test/test_genexps.py
@@ -129,7 +129,7 @@
 Verify re-use of tuples (a side benefit of using genexps over listcomps)
 
     >>> tupleids = map(id, ((i,i) for i in xrange(10)))
-    >>> max(tupleids) - min(tupleids)
+    >>> int(max(tupleids) - min(tupleids))
     0
 
 Verify that syntax error's are raised for genexps used as lvalues
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index d4c681a..748ad44 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -48,7 +48,7 @@
 VERY_LARGE = 0xFF0000121212121212121242L
 
 from _testcapi import UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, INT_MAX, \
-     INT_MIN, LONG_MIN, LONG_MAX
+     INT_MIN, LONG_MIN, LONG_MAX, PY_SSIZE_T_MIN, PY_SSIZE_T_MAX
 
 # fake, they are not defined in Python's header files
 LLONG_MAX = 2**63-1
@@ -182,6 +182,23 @@
         self.failUnlessEqual(42, getargs_l(42L))
         self.assertRaises(OverflowError, getargs_l, VERY_LARGE)
 
+    def test_n(self):
+        from _testcapi import getargs_n
+        # n returns 'Py_ssize_t', and does range checking
+        # (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX)
+        self.failUnlessEqual(3, getargs_n(3.14))
+        self.failUnlessEqual(99, getargs_n(Long()))
+        self.failUnlessEqual(99, getargs_n(Int()))
+
+        self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1)
+        self.failUnlessEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN))
+        self.failUnlessEqual(PY_SSIZE_T_MAX, getargs_n(PY_SSIZE_T_MAX))
+        self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX+1)
+
+        self.failUnlessEqual(42, getargs_n(42))
+        self.failUnlessEqual(42, getargs_n(42L))
+        self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
+
 
 class LongLong_TestCase(unittest.TestCase):
     def test_L(self):
diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py
index 8a6ef7f..5ce09f9 100644
--- a/Lib/test/test_glob.py
+++ b/Lib/test/test_glob.py
@@ -80,6 +80,14 @@
         eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'),
                                                    os.path.join('aab', 'F')]))
 
+    def test_glob_directory_with_trailing_slash(self):
+        # We are verifying that when there is wildcard pattern which
+        # ends with os.sep doesn't blow up.
+        res = glob.glob(self.tempdir + '*' + os.sep)
+        self.assertEqual(len(res), 1)
+        # either of these results are reasonable
+        self.assertTrue(res[0] in [self.tempdir, self.tempdir + os.sep])
+
     def test_glob_broken_symlinks(self):
         if hasattr(os, 'symlink'):
             eq = self.assertSequencesEqual_noorder
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 5b20ab3..4bb4e45 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -255,6 +255,10 @@
 d22v(*(1, 2, 3, 4))
 d22v(1, 2, *(3, 4, 5))
 d22v(1, *(2, 3), **{'d': 4})
+def d31v((x)): pass
+d31v(1)
+def d32v((x,)): pass
+d32v((1,))
 
 ### lambdef: 'lambda' [varargslist] ':' test
 print 'lambdef'
@@ -811,6 +815,11 @@
 x = 5; t = True;
 verify([(i,j) for i in range(10) for j in range(5)] == list(g))
 
+# Grammar allows multiple adjacent 'if's in listcomps and genexps,
+# even though it's silly. Make sure it works (ifelse broke this.)
+verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7])
+verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7])
+
 # Test ifelse expressions in various cases
 def _checkeval(msg, ret):
     "helper to check that evaluation of expressions is done correctly"
diff --git a/Lib/test/test_index.py b/Lib/test/test_index.py
index e69de29..45b3b2b 100644
--- a/Lib/test/test_index.py
+++ b/Lib/test/test_index.py
@@ -0,0 +1,137 @@
+import unittest
+from test import test_support
+import operator
+
+class oldstyle:
+    def __index__(self):
+        return self.ind
+
+class newstyle(object):
+    def __index__(self):
+        return self.ind
+
+class BaseTestCase(unittest.TestCase):
+    def setUp(self):
+        self.o = oldstyle()
+        self.n = newstyle()
+        self.o2 = oldstyle()
+        self.n2 = newstyle()
+
+    def test_basic(self):
+        self.o.ind = -2
+        self.n.ind = 2
+        assert(self.seq[self.n] == self.seq[2])
+        assert(self.seq[self.o] == self.seq[-2])
+        assert(operator.index(self.o) == -2)
+        assert(operator.index(self.n) == 2)
+
+    def test_error(self):
+        self.o.ind = 'dumb'
+        self.n.ind = 'bad'
+        myfunc = lambda x, obj: obj.seq[x]
+        self.failUnlessRaises(TypeError, operator.index, self.o)
+        self.failUnlessRaises(TypeError, operator.index, self.n)
+        self.failUnlessRaises(TypeError, myfunc, self.o, self)
+        self.failUnlessRaises(TypeError, myfunc, self.n, self)
+
+    def test_slice(self):
+        self.o.ind = 1
+        self.o2.ind = 3
+        self.n.ind = 2
+        self.n2.ind = 4
+        assert(self.seq[self.o:self.o2] == self.seq[1:3])
+        assert(self.seq[self.n:self.n2] == self.seq[2:4])
+
+    def test_repeat(self):
+        self.o.ind = 3
+        self.n.ind = 2
+        assert(self.seq * self.o == self.seq * 3)
+        assert(self.seq * self.n == self.seq * 2)
+        assert(self.o * self.seq == self.seq * 3)
+        assert(self.n * self.seq == self.seq * 2)
+
+    def test_wrappers(self):
+        n = self.n
+        n.ind = 5
+        assert n.__index__() == 5
+        assert 6 .__index__() == 6
+        assert -7L.__index__() == -7
+        assert self.seq.__getitem__(n) == self.seq[5]
+        assert self.seq.__mul__(n) == self.seq * 5
+        assert self.seq.__rmul__(n) == self.seq * 5
+
+    def test_infinite_recusion(self):
+        class Trap1(int):
+            def __index__(self):
+                return self
+        class Trap2(long):
+            def __index__(self):
+                return self
+        self.failUnlessRaises(TypeError, operator.getitem, self.seq, Trap1())
+        self.failUnlessRaises(TypeError, operator.getitem, self.seq, Trap2())
+
+
+class ListTestCase(BaseTestCase):
+    seq = [0,10,20,30,40,50]
+
+    def test_setdelitem(self):
+        self.o.ind = -2
+        self.n.ind = 2
+        lst = list('ab!cdefghi!j')
+        del lst[self.o]
+        del lst[self.n]
+        lst[self.o] = 'X'
+        lst[self.n] = 'Y'
+        assert lst == list('abYdefghXj')
+
+        lst = [5, 6, 7, 8, 9, 10, 11]
+        lst.__setitem__(self.n, "here")
+        assert lst == [5, 6, "here", 8, 9, 10, 11]
+        lst.__delitem__(self.n)
+        assert lst == [5, 6, 8, 9, 10, 11]
+
+    def test_inplace_repeat(self):
+        self.o.ind = 2
+        self.n.ind = 3
+        lst = [6, 4]
+        lst *= self.o
+        assert lst == [6, 4, 6, 4]
+        lst *= self.n
+        assert lst == [6, 4, 6, 4] * 3
+
+        lst = [5, 6, 7, 8, 9, 11]
+        l2 = lst.__imul__(self.n)
+        assert l2 is lst
+        assert lst == [5, 6, 7, 8, 9, 11] * 3
+
+
+class TupleTestCase(BaseTestCase):
+    seq = (0,10,20,30,40,50)
+
+class StringTestCase(BaseTestCase):
+    seq = "this is a test"
+
+class UnicodeTestCase(BaseTestCase):
+    seq = u"this is a test"
+
+
+class XRangeTestCase(unittest.TestCase):
+
+    def test_xrange(self):
+        n = newstyle()
+        n.ind = 5
+        assert xrange(1, 20)[n] == 6
+        assert xrange(1, 20).__getitem__(n) == 6
+
+
+def test_main():
+    test_support.run_unittest(
+        ListTestCase,
+        TupleTestCase,
+        StringTestCase,
+        UnicodeTestCase,
+        XRangeTestCase,
+    )
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 0bdf959..d9fd93d 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -295,10 +295,12 @@
         self.assertArgSpecEquals(A.m, ['self'])
 
     def test_getargspec_sublistofone(self):
-        def sublistOfOne((foo)): return 1
-
+        def sublistOfOne((foo,)): return 1
         self.assertArgSpecEquals(sublistOfOne, [['foo']])
 
+        def fakeSublistOfOne((foo)): return 1
+        self.assertArgSpecEquals(fakeSublistOfOne, ['foo'])
+
     def test_classify_newstyle(self):
         class A(object):
 
diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py
index 5939ff5..8c584ad 100644
--- a/Lib/test/test_mimetypes.py
+++ b/Lib/test/test_mimetypes.py
@@ -8,6 +8,7 @@
 # Tell it we don't know about external files:
 mimetypes.knownfiles = []
 mimetypes.inited = False
+mimetypes._default_mime_types()
 
 
 class MimeTypesTestCase(unittest.TestCase):
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index aef7931..4d02dee 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -7,13 +7,114 @@
 
 from test import test_support
 from test import test_multibytecodec_support
-import unittest, StringIO, codecs
+import unittest, StringIO, codecs, sys
+
+class Test_MultibyteCodec(unittest.TestCase):
+
+    def test_nullcoding(self):
+        self.assertEqual(''.decode('gb18030'), u'')
+        self.assertEqual(unicode('', 'gb18030'), u'')
+        self.assertEqual(u''.encode('gb18030'), '')
+
+    def test_str_decode(self):
+        self.assertEqual('abcd'.encode('gb18030'), 'abcd')
+
+    def test_errorcallback_longindex(self):
+        dec = codecs.getdecoder('euc-kr')
+        myreplace  = lambda exc: (u'', sys.maxint+1)
+        codecs.register_error('test.cjktest', myreplace)
+        self.assertRaises(IndexError, dec,
+                          'apple\x92ham\x93spam', 'test.cjktest')
+
+class Test_IncrementalEncoder(unittest.TestCase):
+
+    def test_stateless(self):
+        # cp949 encoder isn't stateful at all.
+        encoder = codecs.getincrementalencoder('cp949')()
+        self.assertEqual(encoder.encode(u'\ud30c\uc774\uc36c \ub9c8\uc744'),
+                         '\xc6\xc4\xc0\xcc\xbd\xe3 \xb8\xb6\xc0\xbb')
+        self.assertEqual(encoder.reset(), None)
+        self.assertEqual(encoder.encode(u'\u2606\u223c\u2606', True),
+                         '\xa1\xd9\xa1\xad\xa1\xd9')
+        self.assertEqual(encoder.reset(), None)
+        self.assertEqual(encoder.encode(u'', True), '')
+        self.assertEqual(encoder.encode(u'', False), '')
+        self.assertEqual(encoder.reset(), None)
+
+    def test_stateful(self):
+        # jisx0213 encoder is stateful for a few codepoints. eg)
+        #   U+00E6 => A9DC
+        #   U+00E6 U+0300 => ABC4
+        #   U+0300 => ABDC
+
+        encoder = codecs.getincrementalencoder('jisx0213')()
+        self.assertEqual(encoder.encode(u'\u00e6\u0300'), '\xab\xc4')
+        self.assertEqual(encoder.encode(u'\u00e6'), '')
+        self.assertEqual(encoder.encode(u'\u0300'), '\xab\xc4')
+        self.assertEqual(encoder.encode(u'\u00e6', True), '\xa9\xdc')
+
+        self.assertEqual(encoder.reset(), None)
+        self.assertEqual(encoder.encode(u'\u0300'), '\xab\xdc')
+
+        self.assertEqual(encoder.encode(u'\u00e6'), '')
+        self.assertEqual(encoder.encode('', True), '\xa9\xdc')
+        self.assertEqual(encoder.encode('', True), '')
+
+    def test_stateful_keep_buffer(self):
+        encoder = codecs.getincrementalencoder('jisx0213')()
+        self.assertEqual(encoder.encode(u'\u00e6'), '')
+        self.assertRaises(UnicodeEncodeError, encoder.encode, u'\u0123')
+        self.assertEqual(encoder.encode(u'\u0300\u00e6'), '\xab\xc4')
+        self.assertRaises(UnicodeEncodeError, encoder.encode, u'\u0123')
+        self.assertEqual(encoder.reset(), None)
+        self.assertEqual(encoder.encode(u'\u0300'), '\xab\xdc')
+        self.assertEqual(encoder.encode(u'\u00e6'), '')
+        self.assertRaises(UnicodeEncodeError, encoder.encode, u'\u0123')
+        self.assertEqual(encoder.encode(u'', True), '\xa9\xdc')
+
+
+class Test_IncrementalDecoder(unittest.TestCase):
+
+    def test_dbcs(self):
+        # cp949 decoder is simple with only 1 or 2 bytes sequences.
+        decoder = codecs.getincrementaldecoder('cp949')()
+        self.assertEqual(decoder.decode('\xc6\xc4\xc0\xcc\xbd'),
+                         u'\ud30c\uc774')
+        self.assertEqual(decoder.decode('\xe3 \xb8\xb6\xc0\xbb'),
+                         u'\uc36c \ub9c8\uc744')
+        self.assertEqual(decoder.decode(''), u'')
+
+    def test_dbcs_keep_buffer(self):
+        decoder = codecs.getincrementaldecoder('cp949')()
+        self.assertEqual(decoder.decode('\xc6\xc4\xc0'), u'\ud30c')
+        self.assertRaises(UnicodeDecodeError, decoder.decode, '', True)
+        self.assertEqual(decoder.decode('\xcc'), u'\uc774')
+
+        self.assertEqual(decoder.decode('\xc6\xc4\xc0'), u'\ud30c')
+        self.assertRaises(UnicodeDecodeError, decoder.decode, '\xcc\xbd', True)
+        self.assertEqual(decoder.decode('\xcc'), u'\uc774')
+
+    def test_iso2022(self):
+        decoder = codecs.getincrementaldecoder('iso2022-jp')()
+        ESC = '\x1b'
+        self.assertEqual(decoder.decode(ESC + '('), u'')
+        self.assertEqual(decoder.decode('B', True), u'')
+        self.assertEqual(decoder.decode(ESC + '$'), u'')
+        self.assertEqual(decoder.decode('B@$'), u'\u4e16')
+        self.assertEqual(decoder.decode('@$@'), u'\u4e16')
+        self.assertEqual(decoder.decode('$', True), u'\u4e16')
+        self.assertEqual(decoder.reset(), None)
+        self.assertEqual(decoder.decode('@$'), u'@$')
+        self.assertEqual(decoder.decode(ESC + '$'), u'')
+        self.assertRaises(UnicodeDecodeError, decoder.decode, '', True)
+        self.assertEqual(decoder.decode('B@$'), u'\u4e16')
+
 
 class Test_StreamWriter(unittest.TestCase):
     if len(u'\U00012345') == 2: # UCS2
         def test_gb18030(self):
             s= StringIO.StringIO()
-            c = codecs.lookup('gb18030')[3](s)
+            c = codecs.getwriter('gb18030')(s)
             c.write(u'123')
             self.assertEqual(s.getvalue(), '123')
             c.write(u'\U00012345')
@@ -30,15 +131,16 @@
             self.assertEqual(s.getvalue(),
                     '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
 
-        # standard utf-8 codecs has broken StreamReader
-        if test_multibytecodec_support.__cjkcodecs__:
-            def test_utf_8(self):
-                s= StringIO.StringIO()
-                c = codecs.lookup('utf-8')[3](s)
-                c.write(u'123')
-                self.assertEqual(s.getvalue(), '123')
-                c.write(u'\U00012345')
-                self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85')
+        def test_utf_8(self):
+            s= StringIO.StringIO()
+            c = codecs.getwriter('utf-8')(s)
+            c.write(u'123')
+            self.assertEqual(s.getvalue(), '123')
+            c.write(u'\U00012345')
+            self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85')
+
+            # Python utf-8 codec can't buffer surrogate pairs yet.
+            if 0:
                 c.write(u'\U00012345'[0])
                 self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85')
                 c.write(u'\U00012345'[1] + u'\U00012345' + u'\uac00\u00ac')
@@ -61,14 +163,6 @@
     else: # UCS4
         pass
 
-    def test_nullcoding(self):
-        self.assertEqual(''.decode('gb18030'), u'')
-        self.assertEqual(unicode('', 'gb18030'), u'')
-        self.assertEqual(u''.encode('gb18030'), '')
-
-    def test_str_decode(self):
-        self.assertEqual('abcd'.encode('gb18030'), 'abcd')
-
     def test_streamwriter_strwrite(self):
         s = StringIO.StringIO()
         wr = codecs.getwriter('gb18030')(s)
@@ -83,6 +177,9 @@
 
 def test_main():
     suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(Test_MultibyteCodec))
+    suite.addTest(unittest.makeSuite(Test_IncrementalEncoder))
+    suite.addTest(unittest.makeSuite(Test_IncrementalDecoder))
     suite.addTest(unittest.makeSuite(Test_StreamWriter))
     suite.addTest(unittest.makeSuite(Test_ISO2022))
     test_support.run_suite(suite)
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
index 45a63e7..bec32de 100644
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -3,15 +3,12 @@
 # test_multibytecodec_support.py
 #   Common Unittest Routines for CJK codecs
 #
-# $CJKCodecs: test_multibytecodec_support.py,v 1.6 2004/06/19 06:09:55 perky Exp $
 
 import sys, codecs, os.path
 import unittest
 from test import test_support
 from StringIO import StringIO
 
-__cjkcodecs__ = 0 # define this as 0 for python
-
 class TestBase:
     encoding        = ''   # codec name
     codec           = None # codec tuple (with 4 elements)
@@ -21,11 +18,17 @@
     roundtriptest   = 1    # set if roundtrip is possible with unicode
     has_iso10646    = 0    # set if this encoding contains whole iso10646 map
     xmlcharnametest = None # string to test xmlcharrefreplace
+    unmappedunicode = u'\udeee' # a unicode codepoint that is not mapped.
 
     def setUp(self):
         if self.codec is None:
             self.codec = codecs.lookup(self.encoding)
-        self.encode, self.decode, self.reader, self.writer = self.codec
+        self.encode = self.codec.encode
+        self.decode = self.codec.decode
+        self.reader = self.codec.streamreader
+        self.writer = self.codec.streamwriter
+        self.incrementalencoder = self.codec.incrementalencoder
+        self.incrementaldecoder = self.codec.incrementaldecoder
 
     def test_chunkcoding(self):
         for native, utf8 in zip(*[StringIO(f).readlines()
@@ -47,51 +50,155 @@
             else:
                 self.assertRaises(UnicodeError, func, source, scheme)
 
-    if sys.hexversion >= 0x02030000:
-        def test_xmlcharrefreplace(self):
-            if self.has_iso10646:
-                return
+    def test_xmlcharrefreplace(self):
+        if self.has_iso10646:
+            return
 
-            s = u"\u0b13\u0b23\u0b60 nd eggs"
-            self.assertEqual(
-                self.encode(s, "xmlcharrefreplace")[0],
-                "&#2835;&#2851;&#2912; nd eggs"
-            )
+        s = u"\u0b13\u0b23\u0b60 nd eggs"
+        self.assertEqual(
+            self.encode(s, "xmlcharrefreplace")[0],
+            "&#2835;&#2851;&#2912; nd eggs"
+        )
 
-        def test_customreplace(self):
-            if self.has_iso10646:
-                return
+    def test_customreplace_encode(self):
+        if self.has_iso10646:
+            return
 
-            import htmlentitydefs
+        from htmlentitydefs import codepoint2name
 
-            names = {}
-            for (key, value) in htmlentitydefs.entitydefs.items():
-                if len(value)==1:
-                    names[value.decode('latin-1')] = self.decode(key)[0]
+        def xmlcharnamereplace(exc):
+            if not isinstance(exc, UnicodeEncodeError):
+                raise TypeError("don't know how to handle %r" % exc)
+            l = []
+            for c in exc.object[exc.start:exc.end]:
+                if ord(c) in codepoint2name:
+                    l.append(u"&%s;" % codepoint2name[ord(c)])
                 else:
-                    names[unichr(int(value[2:-1]))] = self.decode(key)[0]
+                    l.append(u"&#%d;" % ord(c))
+            return (u"".join(l), exc.end)
 
-            def xmlcharnamereplace(exc):
-                if not isinstance(exc, UnicodeEncodeError):
-                    raise TypeError("don't know how to handle %r" % exc)
-                l = []
-                for c in exc.object[exc.start:exc.end]:
-                    try:
-                        l.append(u"&%s;" % names[c])
-                    except KeyError:
-                        l.append(u"&#%d;" % ord(c))
-                return (u"".join(l), exc.end)
+        codecs.register_error("test.xmlcharnamereplace", xmlcharnamereplace)
 
-            codecs.register_error(
-                "test.xmlcharnamereplace", xmlcharnamereplace)
+        if self.xmlcharnametest:
+            sin, sout = self.xmlcharnametest
+        else:
+            sin = u"\xab\u211c\xbb = \u2329\u1234\u232a"
+            sout = "&laquo;&real;&raquo; = &lang;&#4660;&rang;"
+        self.assertEqual(self.encode(sin,
+                                    "test.xmlcharnamereplace")[0], sout)
 
-            if self.xmlcharnametest:
-                sin, sout = self.xmlcharnametest
+    def test_callback_wrong_objects(self):
+        def myreplace(exc):
+            return (ret, exc.end)
+        codecs.register_error("test.cjktest", myreplace)
+
+        for ret in ([1, 2, 3], [], None, object(), 'string', ''):
+            self.assertRaises(TypeError, self.encode, self.unmappedunicode,
+                              'test.cjktest')
+
+    def test_callback_long_index(self):
+        def myreplace(exc):
+            return (u'x', long(exc.end))
+        codecs.register_error("test.cjktest", myreplace)
+        self.assertEqual(self.encode(u'abcd' + self.unmappedunicode + u'efgh',
+                                     'test.cjktest'), ('abcdxefgh', 9))
+
+        def myreplace(exc):
+            return (u'x', sys.maxint + 1)
+        codecs.register_error("test.cjktest", myreplace)
+        self.assertRaises(IndexError, self.encode, self.unmappedunicode,
+                          'test.cjktest')
+
+    def test_callback_None_index(self):
+        def myreplace(exc):
+            return (u'x', None)
+        codecs.register_error("test.cjktest", myreplace)
+        self.assertRaises(TypeError, self.encode, self.unmappedunicode,
+                          'test.cjktest')
+
+    def test_callback_backward_index(self):
+        def myreplace(exc):
+            if myreplace.limit > 0:
+                myreplace.limit -= 1
+                return (u'REPLACED', 0)
             else:
-                sin = u"\xab\u211c\xbb = \u2329\u1234\u232a"
-                sout = "&laquo;&real;&raquo; = &lang;&#4660;&rang;"
-            self.assertEqual(self.encode(sin,
-                                        "test.xmlcharnamereplace")[0], sout)
+                return (u'TERMINAL', exc.end)
+        myreplace.limit = 3
+        codecs.register_error("test.cjktest", myreplace)
+        self.assertEqual(self.encode(u'abcd' + self.unmappedunicode + u'efgh',
+                                     'test.cjktest'),
+                ('abcdREPLACEDabcdREPLACEDabcdREPLACEDabcdTERMINALefgh', 9))
+
+    def test_callback_forward_index(self):
+        def myreplace(exc):
+            return (u'REPLACED', exc.end + 2)
+        codecs.register_error("test.cjktest", myreplace)
+        self.assertEqual(self.encode(u'abcd' + self.unmappedunicode + u'efgh',
+                                     'test.cjktest'), ('abcdREPLACEDgh', 9))
+
+    def test_callback_index_outofbound(self):
+        def myreplace(exc):
+            return (u'TERM', 100)
+        codecs.register_error("test.cjktest", myreplace)
+        self.assertRaises(IndexError, self.encode, self.unmappedunicode,
+                          'test.cjktest')
+
+    def test_incrementalencoder(self):
+        UTF8Reader = codecs.getreader('utf-8')
+        for sizehint in [None] + range(1, 33) + \
+                        [64, 128, 256, 512, 1024]:
+            istream = UTF8Reader(StringIO(self.tstring[1]))
+            ostream = StringIO()
+            encoder = self.incrementalencoder()
+            while 1:
+                if sizehint is not None:
+                    data = istream.read(sizehint)
+                else:
+                    data = istream.read()
+
+                if not data:
+                    break
+                e = encoder.encode(data)
+                ostream.write(e)
+
+            self.assertEqual(ostream.getvalue(), self.tstring[0])
+
+    def test_incrementaldecoder(self):
+        UTF8Writer = codecs.getwriter('utf-8')
+        for sizehint in [None, -1] + range(1, 33) + \
+                        [64, 128, 256, 512, 1024]:
+            istream = StringIO(self.tstring[0])
+            ostream = UTF8Writer(StringIO())
+            decoder = self.incrementaldecoder()
+            while 1:
+                data = istream.read(sizehint)
+                if not data:
+                    break
+                else:
+                    u = decoder.decode(data)
+                    ostream.write(u)
+
+            self.assertEqual(ostream.getvalue(), self.tstring[1])
+
+    def test_incrementalencoder_error_callback(self):
+        inv = self.unmappedunicode
+
+        e = self.incrementalencoder()
+        self.assertRaises(UnicodeEncodeError, e.encode, inv, True)
+
+        e.errors = 'ignore'
+        self.assertEqual(e.encode(inv, True), '')
+
+        e.reset()
+        def tempreplace(exc):
+            return (u'called', exc.end)
+        codecs.register_error('test.incremental_error_callback', tempreplace)
+        e.errors = 'test.incremental_error_callback'
+        self.assertEqual(e.encode(inv, True), 'called')
+
+        # again
+        e.errors = 'ignore'
+        self.assertEqual(e.encode(inv, True), '')
 
     def test_streamreader(self):
         UTF8Writer = codecs.getwriter('utf-8')
@@ -113,11 +220,7 @@
                 self.assertEqual(ostream.getvalue(), self.tstring[1])
 
     def test_streamwriter(self):
-        if __cjkcodecs__:
-            readfuncs = ('read', 'readline', 'readlines')
-        else:
-            # standard utf8 codec has broken readline and readlines.
-            readfuncs = ('read',)
+        readfuncs = ('read', 'readline', 'readlines')
         UTF8Reader = codecs.getreader('utf-8')
         for name in readfuncs:
             for sizehint in [None] + range(1, 33) + \
@@ -211,10 +314,5 @@
             self.assertEqual(unicode(csetch, self.encoding), unich)
 
 def load_teststring(encoding):
-    if __cjkcodecs__:
-        etxt = open(os.path.join('sampletexts', encoding) + '.txt').read()
-        utxt = open(os.path.join('sampletexts', encoding) + '.utf8').read()
-        return (etxt, utxt)
-    else:
-        from test import cjkencodings_test
-        return cjkencodings_test.teststring[encoding]
+    from test import cjkencodings_test
+    return cjkencodings_test.teststring[encoding]
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index cf83d75..f656b9f 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -1382,8 +1382,15 @@
 
 class TestHelp(BaseTest):
     def setUp(self):
+        self.orig_columns = os.environ.get('COLUMNS')
         self.parser = self.make_parser(80)
 
+    def tearDown(self):
+        if self.orig_columns is None:
+            del os.environ['COLUMNS']
+        else:
+            os.environ['COLUMNS'] = self.orig_columns
+
     def make_parser(self, columns):
         options = [
             make_option("-a", type="string", dest='a',
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 771fe9d..8aa1657 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -51,6 +51,10 @@
         self.check_expr("[1, 2, 3]")
         self.check_expr("[x**3 for x in range(20)]")
         self.check_expr("[x**3 for x in range(20) if x % 3]")
+        self.check_expr("[x**3 for x in range(20) if x % 2 if x % 3]")
+        self.check_expr("list(x**3 for x in range(20))")
+        self.check_expr("list(x**3 for x in range(20) if x % 3)")
+        self.check_expr("list(x**3 for x in range(20) if x % 2 if x % 3)")
         self.check_expr("foo(*args)")
         self.check_expr("foo(*args, **kw)")
         self.check_expr("foo(**kw)")
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 200fba5..22307cd 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -63,7 +63,12 @@
         res = platform.dist()
 
     def test_libc_ver(self):
-        res = platform.libc_ver()
+        from sys import executable
+        import os
+        if os.path.isdir(executable) and os.path.exists(executable+'.exe'):
+            # Cygwin horror
+            executable = executable + '.exe'
+        res = platform.libc_ver(executable)
 
 def test_main():
     test_support.run_unittest(
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
index 18142ec..4db3cd1 100644
--- a/Lib/test/test_popen2.py
+++ b/Lib/test/test_popen2.py
@@ -35,6 +35,9 @@
     # same test as popen2._test(), but using the os.popen*() API
     print "Testing os module:"
     import popen2
+    # When the test runs, there shouldn't be any open pipes
+    popen2._cleanup()
+    assert not popen2._active, "Active pipes when test starts " + repr([c.cmd for c in popen2._active])
     cmd  = "cat"
     teststr = "ab cd\n"
     if os.name == "nt":
@@ -65,6 +68,7 @@
         raise ValueError("unexpected %r on stderr" % (got,))
     for inst in popen2._active[:]:
         inst.wait()
+    popen2._cleanup()
     if popen2._active:
         raise ValueError("_active not empty")
     print "All OK"
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 1ccc62b..f98c723 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -73,6 +73,11 @@
             finally:
                 fp.close()
 
+    def test_confstr(self):
+        if hasattr(posix, 'confstr'):
+            self.assertRaises(ValueError, posix.confstr, "CS_garbage")
+            self.assertEqual(len(posix.confstr("CS_PATH")) > 0, True)
+
     def test_dup2(self):
         if hasattr(posix, 'dup2'):
             fp1 = open(test_support.TESTFN)
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index f8ae479..99e01b6 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -18,6 +18,27 @@
     def debug(msg):
         pass
 
+def normalize_output(data):
+    # Some operating systems do conversions on newline.  We could possibly
+    # fix that by doing the appropriate termios.tcsetattr()s.  I couldn't
+    # figure out the right combo on Tru64 and I don't have an IRIX box.
+    # So just normalize the output and doc the problem O/Ses by allowing
+    # certain combinations for some platforms, but avoid allowing other
+    # differences (like extra whitespace, trailing garbage, etc.)
+
+    # This is about the best we can do without getting some feedback
+    # from someone more knowledgable.
+
+    # OSF/1 (Tru64) apparently turns \n into \r\r\n.
+    if data.endswith('\r\r\n'):
+        return data[:-3] + '\n'
+
+    # IRIX apparently turns \n into \r\n.
+    if data.endswith('\r\n'):
+        return data[:-2] + '\n'
+
+    return data
+
 # Marginal testing of pty suite. Cannot do extensive 'do or fail' testing
 # because pty code is not too portable.
 
@@ -36,19 +57,16 @@
     if not os.isatty(slave_fd) and sys.platform not in fickle_isatty:
         raise TestFailed, "slave_fd is not a tty"
 
-    # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other
-    # differences (like extra whitespace, trailing garbage, etc.)
-
     debug("Writing to slave_fd")
     os.write(slave_fd, TEST_STRING_1)
     s1 = os.read(master_fd, 1024)
-    sys.stdout.write(s1.replace("\r\n", "\n"))
+    sys.stdout.write(normalize_output(s1))
 
     debug("Writing chunked output")
     os.write(slave_fd, TEST_STRING_2[:5])
     os.write(slave_fd, TEST_STRING_2[5:])
     s2 = os.read(master_fd, 1024)
-    sys.stdout.write(s2.replace("\r\n", "\n"))
+    sys.stdout.write(normalize_output(s2))
 
     os.close(slave_fd)
     os.close(master_fd)
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 0eb7d90..2410b03 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -97,6 +97,9 @@
                 self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType)))
             else:
                 self.failUnless(isinstance(py_item, (ClassType, type)))
+                if py_item.__module__ != moduleName:
+                    continue   # skip classes that came from somewhere else
+
                 real_bases = [base.__name__ for base in py_item.__bases__]
                 pyclbr_bases = [ getattr(base, 'name', base)
                                  for base in value.super ]
@@ -172,7 +175,7 @@
         cm('pydoc')
 
         # Tests for modules inside packages
-        cm('email.Parser')
+        cm('email.parser')
         cm('test.test_pyclbr')
 
 
diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py
index b55dd01..66977e6 100644
--- a/Lib/test/test_queue.py
+++ b/Lib/test/test_queue.py
@@ -221,7 +221,51 @@
     _doBlockingTest(q.get, (), q.put, ('empty',))
     _doBlockingTest(q.get, (True, 10), q.put, ('empty',))
 
+cum = 0
+cumlock = threading.Lock()
+
+def worker(q):
+    global cum
+    while True:
+        x = q.get()
+        if x is None:
+            q.task_done()
+            return
+        cumlock.acquire()
+        try:
+            cum += x
+        finally:
+            cumlock.release()
+        q.task_done()
+
+def QueueJoinTest(q):
+    global cum
+    cum = 0
+    for i in (0,1):
+        threading.Thread(target=worker, args=(q,)).start()
+    for i in xrange(100):
+        q.put(i)
+    q.join()
+    verify(cum==sum(range(100)), "q.join() did not block until all tasks were done")
+    for i in (0,1):
+        q.put(None)         # instruct the threads to close
+    q.join()                # verify that you can join twice
+
+def QueueTaskDoneTest(q):
+    try:
+        q.task_done()
+    except ValueError:
+        pass
+    else:
+        raise TestFailed("Did not detect task count going negative")
+
 def test():
+    q = Queue.Queue()
+    QueueTaskDoneTest(q)
+    QueueJoinTest(q)
+    QueueJoinTest(q)
+    QueueTaskDoneTest(q)
+
     q = Queue.Queue(QUEUE_SIZE)
     # Do it a couple of times on the same queue
     SimpleQueueTest(q)
diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py
index ed66dfc..631c974 100644
--- a/Lib/test/test_quopri.py
+++ b/Lib/test/test_quopri.py
@@ -1,7 +1,7 @@
 from test import test_support
 import unittest
 
-import sys, os, cStringIO
+import sys, os, cStringIO, subprocess
 import quopri
 
 
@@ -176,17 +176,20 @@
 
     def test_scriptencode(self):
         (p, e) = self.STRINGS[-1]
-        (cin, cout) = os.popen2("%s -mquopri" % sys.executable)
-        cin.write(p)
-        cin.close()
-        self.assert_(cout.read() == e)
+        process = subprocess.Popen([sys.executable, "-mquopri"],
+                                   stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        cout, cerr = process.communicate(p)
+        # On Windows, Python will output the result to stdout using
+        # CRLF, as the mode of stdout is text mode. To compare this
+        # with the expected result, we need to do a line-by-line comparison.
+        self.assert_(cout.splitlines() == e.splitlines())
 
     def test_scriptdecode(self):
         (p, e) = self.STRINGS[-1]
-        (cin, cout) = os.popen2("%s -mquopri -d" % sys.executable)
-        cin.write(e)
-        cin.close()
-        self.assert_(cout.read() == p)
+        process = subprocess.Popen([sys.executable, "-mquopri", "-d"],
+                                   stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        cout, cerr = process.communicate(e)
+        self.assert_(cout.splitlines() == p.splitlines())
 
 def test_main():
     test_support.run_unittest(QuopriTestCase)
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 9c2e0d0..bba4c7c 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -93,10 +93,29 @@
         self.gen.sample(set(range(20)), 2)
         self.gen.sample(range(20), 2)
         self.gen.sample(xrange(20), 2)
-        self.gen.sample(dict.fromkeys('abcdefghijklmnopqrst'), 2)
         self.gen.sample(str('abcdefghijklmnopqrst'), 2)
         self.gen.sample(tuple('abcdefghijklmnopqrst'), 2)
 
+    def test_sample_on_dicts(self):
+        self.gen.sample(dict.fromkeys('abcdefghijklmnopqrst'), 2)
+
+        # SF bug #1460340 -- random.sample can raise KeyError
+        a = dict.fromkeys(range(10)+range(10,100,2)+range(100,110))
+        self.gen.sample(a, 3)
+
+        # A followup to bug #1460340:  sampling from a dict could return
+        # a subset of its keys or of its values, depending on the size of
+        # the subset requested.
+        N = 30
+        d = dict((i, complex(i, i)) for i in xrange(N))
+        for k in xrange(N+1):
+            samp = self.gen.sample(d, k)
+            # Verify that we got ints back (keys); the values are complex.
+            for x in samp:
+                self.assert_(type(x) is int)
+        samp.sort()
+        self.assertEqual(samp, range(N))
+
     def test_gauss(self):
         # Ensure that the seed() method initializes all the hidden state.  In
         # particular, through 2.2.1 it failed to reset a piece of state used
diff --git a/Lib/test/test_regex.py b/Lib/test/test_regex.py
deleted file mode 100644
index 2e2c8f65..0000000
--- a/Lib/test/test_regex.py
+++ /dev/null
@@ -1,113 +0,0 @@
-from test.test_support import verbose, sortdict
-import warnings
-warnings.filterwarnings("ignore", "the regex module is deprecated",
-                        DeprecationWarning, __name__)
-import regex
-from regex_syntax import *
-
-re = 'a+b+c+'
-print 'no match:', regex.match(re, 'hello aaaabcccc world')
-print 'successful search:', regex.search(re, 'hello aaaabcccc world')
-try:
-    cre = regex.compile('\(' + re)
-except regex.error:
-    print 'caught expected exception'
-else:
-    print 'expected regex.error not raised'
-
-print 'failed awk syntax:', regex.search('(a+)|(b+)', 'cdb')
-prev = regex.set_syntax(RE_SYNTAX_AWK)
-print 'successful awk syntax:', regex.search('(a+)|(b+)', 'cdb')
-regex.set_syntax(prev)
-print 'failed awk syntax:', regex.search('(a+)|(b+)', 'cdb')
-
-re = '\(<one>[0-9]+\) *\(<two>[0-9]+\)'
-print 'matching with group names and compile()'
-cre = regex.compile(re)
-print cre.match('801 999')
-try:
-    print cre.group('one')
-except regex.error:
-    print 'caught expected exception'
-else:
-    print 'expected regex.error not raised'
-
-print 'matching with group names and symcomp()'
-cre = regex.symcomp(re)
-print cre.match('801 999')
-print cre.group(0)
-print cre.group('one')
-print cre.group(1, 2)
-print cre.group('one', 'two')
-print 'realpat:', cre.realpat
-print 'groupindex:', sortdict(cre.groupindex)
-
-re = 'world'
-cre = regex.compile(re)
-print 'not case folded search:', cre.search('HELLO WORLD')
-cre = regex.compile(re, regex.casefold)
-print 'case folded search:', cre.search('HELLO WORLD')
-
-print '__members__:', cre.__members__
-print 'regs:', cre.regs
-print 'last:', cre.last
-print 'translate:', len(cre.translate)
-print 'givenpat:', cre.givenpat
-
-print 'match with pos:', cre.match('hello world', 7)
-print 'search with pos:', cre.search('hello world there world', 7)
-print 'bogus group:', cre.group(0, 1, 3)
-try:
-    print 'no name:', cre.group('one')
-except regex.error:
-    print 'caught expected exception'
-else:
-    print 'expected regex.error not raised'
-
-from regex_tests import *
-if verbose: print 'Running regex_tests test suite'
-
-for t in tests:
-    pattern=s=outcome=repl=expected=None
-    if len(t)==5:
-        pattern, s, outcome, repl, expected = t
-    elif len(t)==3:
-        pattern, s, outcome = t
-    else:
-        raise ValueError, ('Test tuples should have 3 or 5 fields',t)
-
-    try:
-        obj=regex.compile(pattern)
-    except regex.error:
-        if outcome==SYNTAX_ERROR: pass    # Expected a syntax error
-        else:
-            # Regex syntax errors aren't yet reported, so for
-            # the official test suite they'll be quietly ignored.
-            pass
-            #print '=== Syntax error:', t
-    else:
-        try:
-            result=obj.search(s)
-        except regex.error, msg:
-            print '=== Unexpected exception', t, repr(msg)
-        if outcome==SYNTAX_ERROR:
-            # This should have been a syntax error; forget it.
-            pass
-        elif outcome==FAIL:
-            if result==-1: pass   # No match, as expected
-            else: print '=== Succeeded incorrectly', t
-        elif outcome==SUCCEED:
-            if result!=-1:
-                # Matched, as expected, so now we compute the
-                # result string and compare it to our expected result.
-                start, end = obj.regs[0]
-                found=s[start:end]
-                groups=obj.group(1,2,3,4,5,6,7,8,9,10)
-                vardict=vars()
-                for i in range(len(groups)):
-                    vardict['g'+str(i+1)]=str(groups[i])
-                repl=eval(repl)
-                if repl!=expected:
-                    print '=== grouping error', t, repr(repl)+' should be '+repr(expected)
-            else:
-                print '=== Failed incorrectly', t
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 6ff1215..0268be2 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -224,7 +224,7 @@
         # Bug #1257731
         class H(self.thetype):
             def __hash__(self):
-                return id(self)
+                return int(id(self) & 0x7fffffff)
         s=H()
         f=set()
         f.add(s)
@@ -421,7 +421,7 @@
         self.assertRaises(ReferenceError, str, p)
 
     # C API test only available in a debug build
-    if hasattr(sys, "gettotalrefcount"):
+    if hasattr(set, "test_c_api"):
         def test_c_api(self):
             self.assertEqual(set('abc').test_c_api(), True)
 
diff --git a/Lib/test/test_setuptools.py b/Lib/test/test_setuptools.py
new file mode 100644
index 0000000..a988303
--- /dev/null
+++ b/Lib/test/test_setuptools.py
@@ -0,0 +1,16 @@
+"""Tests for setuptools.
+
+The tests for setuptools are defined in the setuptools.tests package;
+this runs them from there.
+"""
+
+import test.test_support
+from setuptools.command.test import ScanningLoader
+
+def test_main():
+    test.test_support.run_suite(
+        ScanningLoader().loadTestsFromName('setuptools.tests')
+    )
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_sgmllib.py b/Lib/test/test_sgmllib.py
index bc25bd0..8e8b02f 100644
--- a/Lib/test/test_sgmllib.py
+++ b/Lib/test/test_sgmllib.py
@@ -214,6 +214,20 @@
             ("starttag", "e", [("a", "rgb(1,2,3)")]),
             ])
 
+    def test_attr_values_entities(self):
+        """Substitution of entities and charrefs in attribute values"""
+        # SF bug #1452246
+        self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; '
+                                f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""",
+            [("starttag", "a", [("b", "<"),
+                                ("c", "<>"),
+                                ("d", "&lt->"),
+                                ("e", "< "),
+                                ("f", "&xxx;"),
+                                ("g", " !"),
+                                ("h", "&#500;"),
+                                ("i", "x?a=b&c=d;"), ])])
+
     def test_attr_funky_names(self):
         self.check_events("""<a a.b='v' c:d=v e-f=v>""", [
             ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]),
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 1899e78..6943080 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -268,9 +268,9 @@
             # Probably a similar problem as above; skip this test
             return
         all_host_names = [hostname, hname] + aliases
-        fqhn = socket.getfqdn()
+        fqhn = socket.getfqdn(ip)
         if not fqhn in all_host_names:
-            self.fail("Error testing host resolution mechanisms.")
+            self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
 
     def testRefCountGetNameInfo(self):
         # Testing reference count for getnameinfo
@@ -469,6 +469,14 @@
         sock.close()
         self.assertRaises(socket.error, sock.send, "spam")
 
+    def testNewAttributes(self):
+        # testing .family, .type and .protocol
+        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.assertEqual(sock.family, socket.AF_INET)
+        self.assertEqual(sock.type, socket.SOCK_STREAM)
+        self.assertEqual(sock.proto, 0)
+        sock.close()
+
 class BasicTCPTest(SocketConnectedTest):
 
     def __init__(self, methodName='runTest'):
@@ -817,6 +825,32 @@
         self.assert_(issubclass(socket.gaierror, socket.error))
         self.assert_(issubclass(socket.timeout, socket.error))
 
+class TestLinuxAbstractNamespace(unittest.TestCase):
+
+    UNIX_PATH_MAX = 108
+
+    def testLinuxAbstractNamespace(self):
+        address = "\x00python-test-hello\x00\xff"
+        s1 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        s1.bind(address)
+        s1.listen(1)
+        s2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        s2.connect(s1.getsockname())
+        s1.accept()
+        self.assertEqual(s1.getsockname(), address)
+        self.assertEqual(s2.getpeername(), address)
+
+    def testMaxName(self):
+        address = "\x00" + "h" * (self.UNIX_PATH_MAX - 1)
+        s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        s.bind(address)
+        self.assertEqual(s.getsockname(), address)
+
+    def testNameOverflow(self):
+        address = "\x00" + "h" * self.UNIX_PATH_MAX
+        s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        self.assertRaises(socket.error, s.bind, address)
+
 
 def test_main():
     tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions]
@@ -832,6 +866,8 @@
     ])
     if hasattr(socket, "socketpair"):
         tests.append(BasicSocketPairTest)
+    if sys.platform == 'linux2':
+        tests.append(TestLinuxAbstractNamespace)
     test_support.run_unittest(*tests)
 
 if __name__ == "__main__":
diff --git a/Lib/test/test_socket_ssl.py b/Lib/test/test_socket_ssl.py
index 98680b9..1091383 100644
--- a/Lib/test/test_socket_ssl.py
+++ b/Lib/test/test_socket_ssl.py
@@ -1,5 +1,6 @@
 # Test just the SSL support in the socket module, in a moderately bogus way.
 
+import sys
 from test import test_support
 import socket
 
@@ -13,6 +14,9 @@
 
     import urllib
 
+    if test_support.verbose:
+        print "test_basic ..."
+
     socket.RAND_status()
     try:
         socket.RAND_egd(1)
@@ -26,7 +30,41 @@
     buf = f.read()
     f.close()
 
+def test_timeout():
+    test_support.requires('network')
+
+    if test_support.verbose:
+        print "test_timeout ..."
+
+    # A service which issues a welcome banner (without need to write
+    # anything).
+    # XXX ("gmail.org", 995) has been unreliable so far, from time to time
+    # XXX non-responsive for hours on end (& across all buildbot slaves,
+    # XXX so that's not just a local thing).
+    ADDR = "gmail.org", 995
+
+    s = socket.socket()
+    s.settimeout(30.0)
+    try:
+        s.connect(ADDR)
+    except socket.timeout:
+        print >> sys.stderr, """\
+    WARNING:  an attempt to connect to %r timed out, in
+    test_timeout.  That may be legitimate, but is not the outcome we hoped
+    for.  If this message is seen often, test_timeout should be changed to
+    use a more reliable address.""" % (ADDR,)
+        return
+
+    ss = socket.ssl(s)
+    # Read part of return welcome banner twice.
+    ss.read(1)
+    ss.read(1)
+    s.close()
+
 def test_rude_shutdown():
+    if test_support.verbose:
+        print "test_rude_shutdown ..."
+
     try:
         import threading
     except ImportError:
@@ -74,6 +112,7 @@
         raise test_support.TestSkipped("socket module has no ssl support")
     test_rude_shutdown()
     test_basic()
+    test_timeout()
 
 if __name__ == "__main__":
     test_main()
diff --git a/Lib/test/test_sqlite.py b/Lib/test/test_sqlite.py
new file mode 100644
index 0000000..1b1d0e5
--- /dev/null
+++ b/Lib/test/test_sqlite.py
@@ -0,0 +1,16 @@
+from test.test_support import run_unittest, TestSkipped
+import unittest
+
+try:
+    import _sqlite3
+except ImportError:
+    raise TestSkipped('no sqlite available')
+from sqlite3.test import (dbapi, types, userfunctions,
+                                factory, transactions)
+
+def test_main():
+    run_unittest(dbapi.suite(), types.suite(), userfunctions.suite(),
+                 factory.suite(), transactions.suite())
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py
new file mode 100644
index 0000000..c4d12d7
--- /dev/null
+++ b/Lib/test/test_startfile.py
@@ -0,0 +1,37 @@
+# Ridiculously simple test of the os.startfile function for Windows.
+#
+# empty.vbs is an empty file (except for a comment), which does
+# nothing when run with cscript or wscript.
+#
+# A possible improvement would be to have empty.vbs do something that
+# we can detect here, to make sure that not only the os.startfile()
+# call succeeded, but also the the script actually has run.
+
+import unittest
+from test import test_support
+
+# use this form so that the test is skipped when startfile is not available:
+from os import startfile, path
+
+class TestCase(unittest.TestCase):
+    def test_nonexisting(self):
+        self.assertRaises(OSError, startfile, "nonexisting.vbs")
+
+    def test_nonexisting_u(self):
+        self.assertRaises(OSError, startfile, u"nonexisting.vbs")
+
+    def test_empty(self):
+        empty = path.join(path.dirname(__file__), "empty.vbs")
+        startfile(empty)
+        startfile(empty, "open")
+
+    def test_empty_u(self):
+        empty = path.join(path.dirname(__file__), "empty.vbs")
+        startfile(unicode(empty, "mbcs"))
+        startfile(unicode(empty, "mbcs"), "open")
+
+def test_main():
+    test_support.run_unittest(TestCase)
+
+if __name__=="__main__":
+    test_main()
diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
index fd10b68..af13684 100644
--- a/Lib/test/test_sundry.py
+++ b/Lib/test/test_sundry.py
@@ -12,75 +12,50 @@
 from test.test_support import verbose
 
 import BaseHTTPServer
+import DocXMLRPCServer
 import CGIHTTPServer
-import Queue
 import SimpleHTTPServer
-import SocketServer
+import SimpleXMLRPCServer
 import aifc
-import anydbm
 import audiodev
 import bdb
+import cgitb
 import cmd
 import code
-import codeop
-import colorsys
-import commands
 import compileall
-try:
-    import curses   # not available on Windows
-except ImportError:
-    if verbose:
-        print "skipping curses"
-import dircache
-import dis
-import distutils
-import doctest
-import dumbdbm
 import encodings
-import fnmatch
 import formatter
-import fpformat
 import ftplib
 import getpass
-import glob
 import gopherlib
 import htmlentitydefs
-import htmllib
-import httplib
-import imaplib
+import ihooks
 import imghdr
 import imputil
 import keyword
-import macpath
+import linecache
 import macurl2path
 import mailcap
-import mhlib
-import mimetypes
 import mimify
-import multifile
 import mutex
 import nntplib
 import nturl2path
+import opcode
+import os2emxpath
 import pdb
 import pipes
 #import poplib
 import posixfile
-import profile
 import pstats
 import py_compile
-#import reconvert
-import repr
+import pydoc
+import rexec
 try:
     import rlcompleter   # not available on Windows
 except ImportError:
     if verbose:
         print "skipping rlcompleter"
-import robotparser
 import sched
-import sgmllib
-import shelve
-import shlex
-import shutil
 import smtplib
 import sndhdr
 import statvfs
@@ -90,12 +65,17 @@
 import symbol
 import tabnanny
 import telnetlib
-import test
+import timeit
 import toaiff
-import urllib2
+import token
+try:
+    import tty     # not available on Windows
+except ImportError:
+    if verbose:
+        print "skipping tty"
+
 # Can't test the "user" module -- if the user has a ~/.pythonrc.py, it
 # can screw up all sorts of things (esp. if it prints!).
 #import user
 import webbrowser
-import whichdb
 import xml
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index b98c648..ae2a1c8 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -261,6 +261,11 @@
         self.assert_(vi[3] in ("alpha", "beta", "candidate", "final"))
         self.assert_(isinstance(vi[4], int))
 
+    def test_43581(self):
+        # Can't use sys.stdout, as this is a cStringIO object when
+        # the test runs under regrtest.
+        self.assert_(sys.__stdout__.encoding == sys.__stderr__.encoding)
+
 def test_main():
     test.test_support.run_unittest(SysModuleTest)
 
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index cb19d9e..4309e8c 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -113,8 +113,9 @@
 
         # If we are too close to www.python.org, this test will fail.
         # Pick a host that should be farther away.
-        if socket.getfqdn().split('.')[-2:] == ['python', 'org']:
-            self.addr_remote = ('python.net', 80)
+        if (socket.getfqdn().split('.')[-2:] == ['python', 'org'] or
+            socket.getfqdn().split('.')[-2:-1] == ['xs4all']):
+            self.addr_remote = ('tut.fi', 80)
 
         _t1 = time.time()
         self.failUnlessRaises(socket.error, self.sock.connect,
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index d3c1cc4..b064967 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -1,70 +1,30 @@
-from test.test_support import verbose, findfile, is_resource_enabled, TestFailed
 import os, glob, random
+from cStringIO import StringIO
+from test.test_support import (verbose, findfile, is_resource_enabled,
+                               TestFailed)
 from tokenize import (tokenize, generate_tokens, untokenize,
                       NUMBER, NAME, OP, STRING)
 
-if verbose:
-    print 'starting...'
-
-f = file(findfile('tokenize_tests' + os.extsep + 'txt'))
-tokenize(f.readline)
-f.close()
-
-
-
-###### Test roundtrip for untokenize ##########################
-
+# Test roundtrip for `untokenize`.  `f` is a file path.  The source code in f
+# is tokenized, converted back to source code via tokenize.untokenize(),
+# and tokenized again from the latter.  The test fails if the second
+# tokenization doesn't match the first.
 def test_roundtrip(f):
     ## print 'Testing:', f
-    f = file(f)
+    fobj = open(f)
     try:
-        fulltok = list(generate_tokens(f.readline))
+        fulltok = list(generate_tokens(fobj.readline))
     finally:
-        f.close()
+        fobj.close()
 
     t1 = [tok[:2] for tok in fulltok]
     newtext = untokenize(t1)
     readline = iter(newtext.splitlines(1)).next
     t2 = [tok[:2] for tok in generate_tokens(readline)]
-    assert t1 == t2
+    if t1 != t2:
+        raise TestFailed("untokenize() roundtrip failed for %r" % f)
 
-
-f = findfile('tokenize_tests' + os.extsep + 'txt')
-test_roundtrip(f)
-
-testdir = os.path.dirname(f) or os.curdir
-testfiles = glob.glob(testdir + os.sep + 'test*.py')
-if not is_resource_enabled('compiler'):
-    testfiles = random.sample(testfiles, 10)
-
-for f in testfiles:
-    test_roundtrip(f)
-
-
-###### Test detecton of IndentationError ######################
-
-from cStringIO import StringIO
-
-sampleBadText = """
-def foo():
-    bar
-  baz
-"""
-
-try:
-    for tok in generate_tokens(StringIO(sampleBadText).readline):
-        pass
-except IndentationError:
-    pass
-else:
-    raise TestFailed("Did not detect IndentationError:")
-
-
-###### Test example in the docs ###############################
-
-from decimal import Decimal
-from cStringIO import StringIO
-
+# This is an example from the docs, set up as a doctest.
 def decistmt(s):
     """Substitute Decimals for floats in a string of statements.
 
@@ -73,12 +33,21 @@
     >>> decistmt(s)
     "print +Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7')"
 
-    >>> exec(s)
-    -3.21716034272e-007
+    The format of the exponent is inherited from the platform C library.
+    Known cases are "e-007" (Windows) and "e-07" (not Windows).  Since
+    we're only showing 12 digits, and the 13th isn't close to 5, the
+    rest of the output should be platform-independent.
+
+    >>> exec(s) #doctest: +ELLIPSIS
+    -3.21716034272e-0...7
+
+    Output from calculations with Decimal should be identical across all
+    platforms.
+
     >>> exec(decistmt(s))
     -3.217160342717258261933904529E-7
-
     """
+
     result = []
     g = generate_tokens(StringIO(s).readline)   # tokenize the string
     for toknum, tokval, _, _, _  in g:
@@ -93,8 +62,53 @@
             result.append((toknum, tokval))
     return untokenize(result)
 
-import doctest
-doctest.testmod()
+def test_main():
+    if verbose:
+        print 'starting...'
 
-if verbose:
-    print 'finished'
+    # This displays the tokenization of tokenize_tests.py to stdout, and
+    # regrtest.py checks that this equals the expected output (in the
+    # test/output/ directory).
+    f = open(findfile('tokenize_tests' + os.extsep + 'txt'))
+    tokenize(f.readline)
+    f.close()
+
+    # Now run test_roundtrip() over tokenize_test.py too, and over all
+    # (if the "compiler" resource is enabled) or a small random sample (if
+    # "compiler" is not enabled) of the test*.py files.
+    f = findfile('tokenize_tests' + os.extsep + 'txt')
+    test_roundtrip(f)
+
+    testdir = os.path.dirname(f) or os.curdir
+    testfiles = glob.glob(testdir + os.sep + 'test*.py')
+    if not is_resource_enabled('compiler'):
+        testfiles = random.sample(testfiles, 10)
+
+    for f in testfiles:
+        test_roundtrip(f)
+
+    # Test detecton of IndentationError.
+    sampleBadText = """\
+def foo():
+    bar
+  baz
+"""
+
+    try:
+        for tok in generate_tokens(StringIO(sampleBadText).readline):
+            pass
+    except IndentationError:
+        pass
+    else:
+        raise TestFailed("Did not detect IndentationError:")
+
+    # Run the doctests in this module.
+    from test import test_tokenize  # i.e., this module
+    from test.test_support import run_doctest
+    run_doctest(test_tokenize)
+
+    if verbose:
+        print 'finished'
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 944ff9a..4f946f7 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -13,7 +13,15 @@
                 (1, 'line'),
                 (1, 'return')]
 
-# Armin Rigo's failing example:
+# Many of the tests below are tricky because they involve pass statements.
+# If there is implicit control flow around a pass statement (in an except
+# clause or else caluse) under what conditions do you set a line number
+# following that clause?
+
+
+# The entire "while 0:" statement is optimized away.  No code
+# exists for it, so the line numbers skip directly from "del x"
+# to "x = 1".
 def arigo_example():
     x = 1
     del x
@@ -24,7 +32,6 @@
 arigo_example.events = [(0, 'call'),
                         (1, 'line'),
                         (2, 'line'),
-                        (3, 'line'),
                         (5, 'line'),
                         (5, 'return')]
 
@@ -60,14 +67,16 @@
                       (2, 'return')]
 
 def no_pop_blocks():
-    while 0:
+    y = 1
+    while not y:
         bla
     x = 1
 
 no_pop_blocks.events = [(0, 'call'),
                         (1, 'line'),
-                        (3, 'line'),
-                        (3, 'return')]
+                        (2, 'line'),
+                        (4, 'line'),
+                        (4, 'return')]
 
 def called(): # line -3
     x = 1
@@ -127,6 +136,13 @@
                              (4, 'return')]
 
 # implicit return example
+# This test is interesting because of the else: pass
+# part of the code.  The code generate for the true
+# part of the if contains a jump past the else branch.
+# The compiler then generates an implicit "return None"
+# Internally, the compiler visits the pass statement
+# and stores its line number for use on the next instruction.
+# The next instruction is the implicit return None.
 def ireturn_example():
     a = 5
     b = 5
@@ -140,7 +156,8 @@
                           (2, 'line'),
                           (3, 'line'),
                           (4, 'line'),
-                          (4, 'return')]
+                          (6, 'line'),
+                          (6, 'return')]
 
 # Tight loop with while(1) example (SF #765624)
 def tightloop_example():
@@ -221,14 +238,12 @@
 
     def test_01_basic(self):
         self.run_test(basic)
-## XXX: These tests fail with the new ast compiler.  They must
-## be fixed before a release.
-##    def test_02_arigo(self):
-##        self.run_test(arigo_example)
+    def test_02_arigo(self):
+        self.run_test(arigo_example)
     def test_03_one_instr(self):
         self.run_test(one_instr_line)
-##    def test_04_no_pop_blocks(self):
-##        self.run_test(no_pop_blocks)
+    def test_04_no_pop_blocks(self):
+        self.run_test(no_pop_blocks)
 ##    def test_05_no_pop_tops(self):
 ##        self.run_test(no_pop_tops)
     def test_06_call(self):
@@ -240,8 +255,8 @@
         self.run_test2(settrace_and_return)
     def test_09_settrace_and_raise(self):
         self.run_test2(settrace_and_raise)
-##    def test_10_ireturn(self):
-##        self.run_test(ireturn_example)
+    def test_10_ireturn(self):
+        self.run_test(ireturn_example)
     def test_11_tightloop(self):
         self.run_test(tightloop_example)
     def test_12_tighterloop(self):
@@ -579,17 +594,14 @@
         self.run_test(no_jump_too_far_forwards)
     def test_09_no_jump_too_far_backwards(self):
         self.run_test(no_jump_too_far_backwards)
-# XXX: These tests cause the interpreter to crash.  The frame_setlineno()
-# function no longer works correctly because the lineno table generated by
-# the AST compiler is slightly different than with the old compiler.
-#    def test_10_no_jump_to_except_1(self):
-#        self.run_test(no_jump_to_except_1)
-#    def test_11_no_jump_to_except_2(self):
-#        self.run_test(no_jump_to_except_2)
-#    def test_12_no_jump_to_except_3(self):
-#        self.run_test(no_jump_to_except_3)
-#    def test_13_no_jump_to_except_4(self):
-#        self.run_test(no_jump_to_except_4)
+    def test_10_no_jump_to_except_1(self):
+        self.run_test(no_jump_to_except_1)
+    def test_11_no_jump_to_except_2(self):
+        self.run_test(no_jump_to_except_2)
+    def test_12_no_jump_to_except_3(self):
+        self.run_test(no_jump_to_except_3)
+    def test_13_no_jump_to_except_4(self):
+        self.run_test(no_jump_to_except_4)
     def test_14_no_jump_forwards_into_block(self):
         self.run_test(no_jump_forwards_into_block)
     def test_15_no_jump_backwards_into_block(self):
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 29a120f..22c0456 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -24,6 +24,9 @@
         # XXX why doesn't compile raise the same traceback?
         import test.badsyntax_nocaret
 
+    def syntax_error_bad_indentation(self):
+        compile("def spam():\n  print 1\n print 2", "?", "exec")
+
     def test_caret(self):
         err = self.get_exception_format(self.syntax_error_with_caret,
                                         SyntaxError)
@@ -40,6 +43,13 @@
         self.assert_(len(err) == 3)
         self.assert_(err[1].strip() == "[x for x in x] = x")
 
+    def test_bad_indentation(self):
+        err = self.get_exception_format(self.syntax_error_bad_indentation,
+                                        IndentationError)
+        self.assert_(len(err) == 4)
+        self.assert_("^" in err[2])
+        self.assert_(err[1].strip() == "print 2")
+
     def test_bug737473(self):
         import sys, os, tempfile, time
 
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 49ef29d..c7113b5 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -810,6 +810,22 @@
         self.assertEqual(str(Foo9("foo")), "string")
         self.assertEqual(unicode(Foo9("foo")), u"not unicode")
 
+    def test_unicode_repr(self):
+        class s1:
+            def __repr__(self):
+                return '\\n'
+
+        class s2:
+            def __repr__(self):
+                return u'\\n'
+
+        self.assertEqual(repr(s1()), '\\n')
+        self.assertEqual(repr(s2()), '\\n')
+
+
+
+
+
 def test_main():
     test_support.run_unittest(UnicodeTest)
 
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 2843138..64a2ee9 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -13,8 +13,7 @@
 # parse_keqv_list, parse_http_list (I'm leaving this for Anthony Baxter
 #  and Greg Stein, since they're doing Digest Authentication)
 # Authentication stuff (ditto)
-# ProxyHandler, CustomProxy, CustomProxyHandler (I don't use a proxy)
-# GopherHandler (haven't used gopher for a decade or so...)
+# CustomProxy, CustomProxyHandler
 
 class TrivialTests(unittest.TestCase):
     def test_trivial(self):
@@ -90,6 +89,7 @@
         return self.handle(self.meth_name, self.action, *args)
 
 class MockHandler:
+    handler_order = 500
     def __init__(self, methods):
         self._define_methods(methods)
     def _define_methods(self, methods):
@@ -154,7 +154,7 @@
     for meths in meth_spec:
         class MockHandlerSubclass(MockHandler): pass
         h = MockHandlerSubclass(meths)
-        h.handler_order = count
+        h.handler_order += count
         h.add_parent(opener)
         count = count + 1
         handlers.append(h)
@@ -349,13 +349,19 @@
         TESTFN = test_support.TESTFN
         urlpath = sanepathname2url(os.path.abspath(TESTFN))
         towrite = "hello, world\n"
-        for url in [
+        urls = [
             "file://localhost%s" % urlpath,
             "file://%s" % urlpath,
             "file://%s%s" % (socket.gethostbyname('localhost'), urlpath),
-            "file://%s%s" % (socket.gethostbyname(socket.gethostname()),
-                             urlpath),
-            ]:
+            ]
+        try:
+            localaddr = socket.gethostbyname(socket.gethostname())
+        except socket.gaierror:
+            localaddr = ''
+        if localaddr:
+            urls.append("file://%s%s" % (localaddr, urlpath))
+
+        for url in urls:
             f = open(TESTFN, "wb")
             try:
                 try:
@@ -636,6 +642,23 @@
         o.open("http://www.example.com/")
         self.assert_(not hh.req.has_header("Cookie"))
 
+    def test_proxy(self):
+        o = OpenerDirector()
+        ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128"))
+        o.add_handler(ph)
+        meth_spec = [
+            [("http_open", "return response")]
+            ]
+        handlers = add_ordered_mock_handlers(o, meth_spec)
+
+        req = Request("http://acme.example.com/")
+        self.assertEqual(req.get_host(), "acme.example.com")
+        r = o.open(req)
+        self.assertEqual(req.get_host(), "proxy.example.com:3128")
+
+        self.assertEqual([(handlers[0], "http_open")],
+                         [tup[0:2] for tup in o.calls])
+
 
 class MiscTests(unittest.TestCase):
 
@@ -821,6 +844,7 @@
 
 
 def test_main(verbose=None):
+    test_support.run_doctest(urllib2, verbose)
     tests = (TrivialTests,
              OpenerDirectorTests,
              HandlerTests,
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 39ada06..5cee458 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -12,15 +12,53 @@
     def checkRoundtrips(self, url, parsed, split):
         result = urlparse.urlparse(url)
         self.assertEqual(result, parsed)
+        t = (result.scheme, result.netloc, result.path,
+             result.params, result.query, result.fragment)
+        self.assertEqual(t, parsed)
         # put it back together and it should be the same
         result2 = urlparse.urlunparse(result)
         self.assertEqual(result2, url)
+        self.assertEqual(result2, result.geturl())
+
+        # the result of geturl() is a fixpoint; we can always parse it
+        # again to get the same result:
+        result3 = urlparse.urlparse(result.geturl())
+        self.assertEqual(result3.geturl(), result.geturl())
+        self.assertEqual(result3,          result)
+        self.assertEqual(result3.scheme,   result.scheme)
+        self.assertEqual(result3.netloc,   result.netloc)
+        self.assertEqual(result3.path,     result.path)
+        self.assertEqual(result3.params,   result.params)
+        self.assertEqual(result3.query,    result.query)
+        self.assertEqual(result3.fragment, result.fragment)
+        self.assertEqual(result3.username, result.username)
+        self.assertEqual(result3.password, result.password)
+        self.assertEqual(result3.hostname, result.hostname)
+        self.assertEqual(result3.port,     result.port)
 
         # check the roundtrip using urlsplit() as well
         result = urlparse.urlsplit(url)
         self.assertEqual(result, split)
+        t = (result.scheme, result.netloc, result.path,
+             result.query, result.fragment)
+        self.assertEqual(t, split)
         result2 = urlparse.urlunsplit(result)
         self.assertEqual(result2, url)
+        self.assertEqual(result2, result.geturl())
+
+        # check the fixpoint property of re-parsing the result of geturl()
+        result3 = urlparse.urlsplit(result.geturl())
+        self.assertEqual(result3.geturl(), result.geturl())
+        self.assertEqual(result3,          result)
+        self.assertEqual(result3.scheme,   result.scheme)
+        self.assertEqual(result3.netloc,   result.netloc)
+        self.assertEqual(result3.path,     result.path)
+        self.assertEqual(result3.query,    result.query)
+        self.assertEqual(result3.fragment, result.fragment)
+        self.assertEqual(result3.username, result.username)
+        self.assertEqual(result3.password, result.password)
+        self.assertEqual(result3.hostname, result.hostname)
+        self.assertEqual(result3.port,     result.port)
 
     def test_roundtrips(self):
         testcases = [
@@ -187,6 +225,69 @@
             ]:
             self.assertEqual(urlparse.urldefrag(url), (defrag, frag))
 
+    def test_urlsplit_attributes(self):
+        url = "HTTP://WWW.PYTHON.ORG/doc/#frag"
+        p = urlparse.urlsplit(url)
+        self.assertEqual(p.scheme, "http")
+        self.assertEqual(p.netloc, "WWW.PYTHON.ORG")
+        self.assertEqual(p.path, "/doc/")
+        self.assertEqual(p.query, "")
+        self.assertEqual(p.fragment, "frag")
+        self.assertEqual(p.username, None)
+        self.assertEqual(p.password, None)
+        self.assertEqual(p.hostname, "www.python.org")
+        self.assertEqual(p.port, None)
+        # geturl() won't return exactly the original URL in this case
+        # since the scheme is always case-normalized
+        #self.assertEqual(p.geturl(), url)
+
+        url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag"
+        p = urlparse.urlsplit(url)
+        self.assertEqual(p.scheme, "http")
+        self.assertEqual(p.netloc, "User:Pass@www.python.org:080")
+        self.assertEqual(p.path, "/doc/")
+        self.assertEqual(p.query, "query=yes")
+        self.assertEqual(p.fragment, "frag")
+        self.assertEqual(p.username, "User")
+        self.assertEqual(p.password, "Pass")
+        self.assertEqual(p.hostname, "www.python.org")
+        self.assertEqual(p.port, 80)
+        self.assertEqual(p.geturl(), url)
+
+    def test_attributes_bad_port(self):
+        """Check handling of non-integer ports."""
+        p = urlparse.urlsplit("http://www.example.net:foo")
+        self.assertEqual(p.netloc, "www.example.net:foo")
+        self.assertRaises(ValueError, lambda: p.port)
+
+        p = urlparse.urlparse("http://www.example.net:foo")
+        self.assertEqual(p.netloc, "www.example.net:foo")
+        self.assertRaises(ValueError, lambda: p.port)
+
+    def test_attributes_without_netloc(self):
+        # This example is straight from RFC 3261.  It looks like it
+        # should allow the username, hostname, and port to be filled
+        # in, but doesn't.  Since it's a URI and doesn't use the
+        # scheme://netloc syntax, the netloc and related attributes
+        # should be left empty.
+        uri = "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
+        p = urlparse.urlsplit(uri)
+        self.assertEqual(p.netloc, "")
+        self.assertEqual(p.username, None)
+        self.assertEqual(p.password, None)
+        self.assertEqual(p.hostname, None)
+        self.assertEqual(p.port, None)
+        self.assertEqual(p.geturl(), uri)
+
+        p = urlparse.urlparse(uri)
+        self.assertEqual(p.netloc, "")
+        self.assertEqual(p.username, None)
+        self.assertEqual(p.password, None)
+        self.assertEqual(p.hostname, None)
+        self.assertEqual(p.port, None)
+        self.assertEqual(p.geturl(), uri)
+
+
 def test_main():
     test_support.run_unittest(UrlParseTestCase)
 
diff --git a/Lib/test/test_wait3.py b/Lib/test/test_wait3.py
new file mode 100644
index 0000000..f6a41a6
--- /dev/null
+++ b/Lib/test/test_wait3.py
@@ -0,0 +1,32 @@
+"""This test checks for correct wait3() behavior.
+"""
+
+import os
+from test.fork_wait import ForkWait
+from test.test_support import TestSkipped, run_unittest
+
+try:
+    os.fork
+except AttributeError:
+    raise TestSkipped, "os.fork not defined -- skipping test_wait3"
+
+try:
+    os.wait3
+except AttributeError:
+    raise TestSkipped, "os.wait3 not defined -- skipping test_wait3"
+
+class Wait3Test(ForkWait):
+    def wait_impl(self, cpid):
+        while 1:
+            spid, status, rusage = os.wait3(0)
+            if spid == cpid:
+                break
+        self.assertEqual(spid, cpid)
+        self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
+        self.assertTrue(rusage)
+
+def test_main():
+    run_unittest(Wait3Test)
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_wait4.py b/Lib/test/test_wait4.py
new file mode 100644
index 0000000..027e5c3
--- /dev/null
+++ b/Lib/test/test_wait4.py
@@ -0,0 +1,29 @@
+"""This test checks for correct wait4() behavior.
+"""
+
+import os
+from test.fork_wait import ForkWait
+from test.test_support import TestSkipped, run_unittest
+
+try:
+    os.fork
+except AttributeError:
+    raise TestSkipped, "os.fork not defined -- skipping test_wait4"
+
+try:
+    os.wait4
+except AttributeError:
+    raise TestSkipped, "os.wait4 not defined -- skipping test_wait4"
+
+class Wait4Test(ForkWait):
+    def wait_impl(self, cpid):
+        spid, status, rusage = os.wait4(cpid, 0)
+        self.assertEqual(spid, cpid)
+        self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
+        self.assertTrue(rusage)
+
+def test_main():
+    run_unittest(Wait4Test)
+
+if __name__ == "__main__":
+    test_main()
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index b7061c1..5d051a5 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -82,6 +82,10 @@
         self.assertEqual(msg.category, 'UserWarning')
 
 def test_main(verbose=None):
+    # Obscure hack so that this test passes after reloads or repeated calls
+    # to test_main (regrtest -R).
+    if '__warningregistry__' in globals():
+        del globals()['__warningregistry__']
     test_support.run_unittest(TestModule)
 
 if __name__ == "__main__":
diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py
index 77c432a..19d4459 100644
--- a/Lib/test/test_winsound.py
+++ b/Lib/test/test_winsound.py
@@ -3,6 +3,9 @@
 import unittest
 from test import test_support
 import winsound, time
+import os
+import subprocess
+
 
 class BeepTest(unittest.TestCase):
 
@@ -44,6 +47,7 @@
     def test_question(self):
         winsound.MessageBeep(winsound.MB_ICONQUESTION)
 
+
 class PlaySoundTest(unittest.TestCase):
 
     def test_errors(self):
@@ -56,19 +60,54 @@
         )
 
     def test_alias_asterisk(self):
-        winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
+        if _have_soundcard():
+            winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
+        else:
+            self.assertRaises(
+                RuntimeError,
+                winsound.PlaySound,
+                'SystemAsterisk', winsound.SND_ALIAS
+            )
 
     def test_alias_exclamation(self):
-        winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS)
+        if _have_soundcard():
+            winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS)
+        else:
+            self.assertRaises(
+                RuntimeError,
+                winsound.PlaySound,
+                'SystemExclamation', winsound.SND_ALIAS
+            )
 
     def test_alias_exit(self):
-        winsound.PlaySound('SystemExit', winsound.SND_ALIAS)
+        if _have_soundcard():
+            winsound.PlaySound('SystemExit', winsound.SND_ALIAS)
+        else:
+            self.assertRaises(
+                RuntimeError,
+                winsound.PlaySound,
+                'SystemExit', winsound.SND_ALIAS
+            )
 
     def test_alias_hand(self):
-        winsound.PlaySound('SystemHand', winsound.SND_ALIAS)
+        if _have_soundcard():
+            winsound.PlaySound('SystemHand', winsound.SND_ALIAS)
+        else:
+            self.assertRaises(
+                RuntimeError,
+                winsound.PlaySound,
+                'SystemHand', winsound.SND_ALIAS
+            )
 
     def test_alias_question(self):
-        winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
+        if _have_soundcard():
+            winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
+        else:
+            self.assertRaises(
+                RuntimeError,
+                winsound.PlaySound,
+                'SystemQuestion', winsound.SND_ALIAS
+            )
 
     def test_alias_fallback(self):
         # This test can't be expected to work on all systems.  The MS
@@ -85,41 +124,83 @@
         return
 
     def test_alias_nofallback(self):
-        # Note that this is not the same as asserting RuntimeError
-        # will get raised:  you cannot convert this to
-        # self.assertRaises(...) form.  The attempt may or may not
-        # raise RuntimeError, but it shouldn't raise anything other
-        # than RuntimeError, and that's all we're trying to test here.
-        # The MS docs aren't clear about whether the SDK PlaySound()
-        # with SND_ALIAS and SND_NODEFAULT will return True or False when
-        # the alias is unknown.  On Tim's WinXP box today, it returns
-        # True (no exception is raised).  What we'd really like to test
-        # is that no sound is played, but that requires first wiring an
-        # eardrum class into unittest <wink>.
-        try:
-            winsound.PlaySound(
-                '!"$%&/(#+*',
-                winsound.SND_ALIAS | winsound.SND_NODEFAULT
+        if _have_soundcard():
+            # Note that this is not the same as asserting RuntimeError
+            # will get raised:  you cannot convert this to
+            # self.assertRaises(...) form.  The attempt may or may not
+            # raise RuntimeError, but it shouldn't raise anything other
+            # than RuntimeError, and that's all we're trying to test
+            # here.  The MS docs aren't clear about whether the SDK
+            # PlaySound() with SND_ALIAS and SND_NODEFAULT will return
+            # True or False when the alias is unknown.  On Tim's WinXP
+            # box today, it returns True (no exception is raised).  What
+            # we'd really like to test is that no sound is played, but
+            # that requires first wiring an eardrum class into unittest
+            # <wink>.
+            try:
+                winsound.PlaySound(
+                    '!"$%&/(#+*',
+                    winsound.SND_ALIAS | winsound.SND_NODEFAULT
+                )
+            except RuntimeError:
+                pass
+        else:
+            self.assertRaises(
+                RuntimeError,
+                winsound.PlaySound,
+                '!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT
             )
-        except RuntimeError:
-            pass
 
     def test_stopasync(self):
-        winsound.PlaySound(
-            'SystemQuestion',
-            winsound.SND_ALIAS | winsound.SND_ASYNC | winsound.SND_LOOP
-        )
-        time.sleep(0.5)
-        try:
+        if _have_soundcard():
             winsound.PlaySound(
                 'SystemQuestion',
-                winsound.SND_ALIAS | winsound.SND_NOSTOP
+                winsound.SND_ALIAS | winsound.SND_ASYNC | winsound.SND_LOOP
             )
-        except RuntimeError:
-            pass
-        else: # the first sound might already be finished
-            pass
-        winsound.PlaySound(None, winsound.SND_PURGE)
+            time.sleep(0.5)
+            try:
+                winsound.PlaySound(
+                    'SystemQuestion',
+                    winsound.SND_ALIAS | winsound.SND_NOSTOP
+                )
+            except RuntimeError:
+                pass
+            else: # the first sound might already be finished
+                pass
+            winsound.PlaySound(None, winsound.SND_PURGE)
+        else:
+            self.assertRaises(
+                RuntimeError,
+                winsound.PlaySound,
+                None, winsound.SND_PURGE
+            )
+
+
+def _get_cscript_path():
+    """Return the full path to cscript.exe or None."""
+    for dir in os.environ.get("PATH", "").split(os.pathsep):
+        cscript_path = os.path.join(dir, "cscript.exe")
+        if os.path.exists(cscript_path):
+            return cscript_path
+
+__have_soundcard_cache = None
+def _have_soundcard():
+    """Return True iff this computer has a soundcard."""
+    global __have_soundcard_cache
+    if __have_soundcard_cache is None:
+        cscript_path = _get_cscript_path()
+        if cscript_path is None:
+            # Could not find cscript.exe to run our VBScript helper. Default
+            # to True: most computers these days *do* have a soundcard.
+            return True
+
+        check_script = os.path.join(os.path.dirname(__file__),
+                                    "check_soundcard.vbs")
+        p = subprocess.Popen([cscript_path, check_script],
+                             stdout=subprocess.PIPE)
+        __have_soundcard_cache = not p.wait()
+    return __have_soundcard_cache
+
 
 def test_main():
     test_support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest)
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index 4854436..48e00f4 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -494,6 +494,62 @@
         self.assertAfterWithGeneratorInvariantsWithError(self.foo)
         self.assertAfterWithGeneratorInvariantsNoError(self.bar)
 
+    def testRaisedStopIteration1(self):
+        @contextmanager
+        def cm():
+            yield
+
+        def shouldThrow():
+            with cm():
+                raise StopIteration("from with")
+
+        self.assertRaises(StopIteration, shouldThrow)
+
+    def testRaisedStopIteration2(self):
+        class cm (object):
+            def __context__(self):
+                return self
+
+            def __enter__(self):
+                pass
+
+            def __exit__(self, type, value, traceback):
+                pass
+
+        def shouldThrow():
+            with cm():
+                raise StopIteration("from with")
+
+        self.assertRaises(StopIteration, shouldThrow)
+
+    def testRaisedGeneratorExit1(self):
+        @contextmanager
+        def cm():
+            yield
+
+        def shouldThrow():
+            with cm():
+                raise GeneratorExit("from with")
+
+        self.assertRaises(GeneratorExit, shouldThrow)
+
+    def testRaisedGeneratorExit2(self):
+        class cm (object):
+            def __context__(self):
+                return self
+
+            def __enter__(self):
+                pass
+
+            def __exit__(self, type, value, traceback):
+                pass
+
+        def shouldThrow():
+            with cm():
+                raise GeneratorExit("from with")
+
+        self.assertRaises(GeneratorExit, shouldThrow)
+
 
 class NonLocalFlowControlTestCase(unittest.TestCase):
 
diff --git a/Lib/test/test_xrange.py b/Lib/test/test_xrange.py
index 40590cd..c0d1dbe 100644
--- a/Lib/test/test_xrange.py
+++ b/Lib/test/test_xrange.py
@@ -57,12 +57,7 @@
         self.assertRaises(OverflowError, xrange, 0, 2*sys.maxint)
 
         r = xrange(-sys.maxint, sys.maxint, 2)
-        if sys.maxint > 0x7fffffff:
-            # XXX raising ValueError is less than ideal, but this can't
-            # be fixed until range_length() returns a long in rangeobject.c
-            self.assertRaises(ValueError, len, r)
-        else:
-            self.assertEqual(len(r), sys.maxint)
+        self.assertEqual(len(r), sys.maxint)
         self.assertRaises(OverflowError, xrange, -sys.maxint-1, sys.maxint, 2)
 
 def test_main():
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index eb7cbf6..4e1a845 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -12,7 +12,12 @@
 from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co
 
 import zipimport
-
+import linecache
+import doctest
+import inspect
+import StringIO
+from traceback import extract_tb, extract_stack, print_tb
+raise_src = 'def do_raise(): raise TypeError\n'
 
 # so we only run testAFakeZlib once if this test is run repeatedly
 # which happens when we look for ref leaks
@@ -54,7 +59,8 @@
 
     def setUp(self):
         # We're reusing the zip archive path, so we must clear the
-        # cached directory info.
+        # cached directory info and linecache
+        linecache.clearcache()
         zipimport._zip_directory_cache.clear()
         ImportHooksBaseTestCase.setUp(self)
 
@@ -83,6 +89,11 @@
 
             mod = __import__(".".join(modules), globals(), locals(),
                              ["__dummy__"])
+
+            call = kw.get('call')
+            if call is not None:
+                call(mod)
+
             if expected_ext:
                 file = mod.get_file()
                 self.assertEquals(file, os.path.join(TEMP_ZIP,
@@ -249,6 +260,74 @@
         self.doTest(".py", files, TESTMOD,
                     stuff="Some Stuff"*31)
 
+    def assertModuleSource(self, module):
+        self.assertEqual(inspect.getsource(module), test_src)
+
+    def testGetSource(self):
+        files = {TESTMOD + ".py": (NOW, test_src)}
+        self.doTest(".py", files, TESTMOD, call=self.assertModuleSource)
+
+    def testGetCompiledSource(self):
+        pyc = make_pyc(compile(test_src, "<???>", "exec"), NOW)
+        files = {TESTMOD + ".py": (NOW, test_src),
+                 TESTMOD + pyc_ext: (NOW, pyc)}
+        self.doTest(pyc_ext, files, TESTMOD, call=self.assertModuleSource)
+
+    def runDoctest(self, callback):
+        files = {TESTMOD + ".py": (NOW, test_src),
+                 "xyz.txt": (NOW, ">>> log.append(True)\n")}
+        self.doTest(".py", files, TESTMOD, call=callback)
+
+    def doDoctestFile(self, module):
+        log = []
+        old_master, doctest.master = doctest.master, None
+        try:
+            doctest.testfile(
+                'xyz.txt', package=module, module_relative=True,
+                globs=locals()
+            )
+        finally:
+            doctest.master = old_master
+        self.assertEqual(log,[True])
+
+    def testDoctestFile(self):
+        self.runDoctest(self.doDoctestFile)
+
+    def doDoctestSuite(self, module):
+        log = []
+        doctest.DocFileTest(
+            'xyz.txt', package=module, module_relative=True,
+            globs=locals()
+        ).run()
+        self.assertEqual(log,[True])
+
+    def testDoctestSuite(self):
+        self.runDoctest(self.doDoctestSuite)
+
+
+    def doTraceback(self, module):
+        try:
+            module.do_raise()
+        except:
+            tb = sys.exc_info()[2].tb_next
+
+            f,lno,n,line = extract_tb(tb, 1)[0]
+            self.assertEqual(line, raise_src.strip())
+
+            f,lno,n,line = extract_stack(tb.tb_frame, 1)[0]
+            self.assertEqual(line, raise_src.strip())
+
+            s = StringIO.StringIO()
+            print_tb(tb, 1, s)
+            self.failUnless(s.getvalue().endswith(raise_src))
+        else:
+            raise AssertionError("This ought to be impossible")
+
+    def testTraceback(self):
+        files = {TESTMOD + ".py": (NOW, raise_src)}
+        self.doTest(None, files, TESTMOD, call=self.doTraceback)
+
+
 class CompressedZipImportTestCase(UncompressedZipImportTestCase):
     compression = ZIP_DEFLATED