Bug #1486663: don't reject keyword arguments for subclasses of builtin
types.
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 06f13cd..63e7f4e 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -12,6 +12,10 @@
 class ArraySubclass(array.array):
     pass
 
+class ArraySubclassWithKwargs(array.array):
+    def __init__(self, typecode, newarg=None):
+        array.array.__init__(typecode)
+
 tests = [] # list to accumulate all tests
 typecodes = "cubBhHiIlLfd"
 
@@ -683,6 +687,9 @@
                 b = array.array('B', range(64))
             self.assertEqual(rc, sys.getrefcount(10))
 
+    def test_subclass_with_kwargs(self):
+        # SF bug #1486663 -- this used to erroneously raise a TypeError
+        ArraySubclassWithKwargs('b', newarg=1)
 
 
 class StringTest(BaseTest):
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 35e1536..1d996ee 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -486,6 +486,16 @@
         d1 == d2   # not clear if this is supposed to be True or False,
                    # but it used to give a SystemError
 
+
+class SubclassWithKwargs(deque):
+    def __init__(self, newarg=1):
+        deque.__init__(self)
+
+class TestSubclassWithKwargs(unittest.TestCase):
+    def test_subclass_with_kwargs(self):
+        # SF bug #1486663 -- this used to erroneously raise a TypeError
+        SubclassWithKwargs(newarg=1)
+
 #==============================================================================
 
 libreftest = """
@@ -599,6 +609,7 @@
         TestBasic,
         TestVariousIteratorArgs,
         TestSubclass,
+        TestSubclassWithKwargs,
     )
 
     test_support.run_unittest(*test_classes)
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 2baa507..5e375c9 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -740,6 +740,21 @@
         self.assertRaises(AssertionError, list, cycle(gen1()))
         self.assertEqual(hist, [0,1])
 
+class SubclassWithKwargsTest(unittest.TestCase):
+    def test_keywords_in_subclass(self):
+        # count is not subclassable...
+        for cls in (repeat, izip, ifilter, ifilterfalse, chain, imap,
+                    starmap, islice, takewhile, dropwhile, cycle):
+            class Subclass(cls):
+                def __init__(self, newarg=None, *args):
+                    cls.__init__(self, *args)
+            try:
+                Subclass(newarg=1)
+            except TypeError, err:
+                # we expect type errors because of wrong argument count
+                self.failIf("does not take keyword arguments" in err.args[0])
+
+
 libreftest = """ Doctest for examples in the library reference: libitertools.tex
 
 
@@ -934,7 +949,8 @@
 
 def test_main(verbose=None):
     test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
-                    RegressionTests, LengthTransparency)
+                    RegressionTests, LengthTransparency,
+                    SubclassWithKwargsTest)
     test_support.run_unittest(*test_classes)
 
     # verify reference counting
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index ddbcc2f..77bccf6 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -515,6 +515,14 @@
         # tests validity but not completeness of the __all__ list
         self.failUnless(set(random.__all__) <= set(dir(random)))
 
+    def test_random_subclass_with_kwargs(self):
+        # SF bug #1486663 -- this used to erroneously raise a TypeError
+        class Subclass(random.Random):
+            def __init__(self, newarg=None):
+                random.Random.__init__(self)
+        Subclass(newarg=1)
+
+
 def test_main(verbose=None):
     testclasses =    [WichmannHill_TestBasicOps,
                       MersenneTwister_TestBasicOps,