[pypy-svn] r58817 - in pypy/branch/2.5-merge/pypy/lib: . app_test test2

iko at codespeak.net iko at codespeak.net
Wed Oct 8 15:02:24 CEST 2008


Author: iko
Date: Wed Oct  8 15:02:23 2008
New Revision: 58817

Added:
   pypy/branch/2.5-merge/pypy/lib/test2/test_collections.py   (contents, props changed)
      - copied, changed from r58815, pypy/branch/2.5-merge/pypy/lib/app_test/test_collections.py
Removed:
   pypy/branch/2.5-merge/pypy/lib/app_test/test_collections.py
Modified:
   pypy/branch/2.5-merge/pypy/lib/collections.py
Log:
(iko, cfbolz)
allow deque subclasses to have extra args in __init__



Modified: pypy/branch/2.5-merge/pypy/lib/collections.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/lib/collections.py	(original)
+++ pypy/branch/2.5-merge/pypy/lib/collections.py	Wed Oct  8 15:02:23 2008
@@ -20,8 +20,8 @@
 
 class deque(object):
 
-    def __new__(cls, iterable=()):
-        self = super(deque, cls).__new__(cls)
+    def __new__(cls, iterable=(), *args, **kw):
+        self = super(deque, cls).__new__(cls, *args, **kw)
         self.clear()
         return self
 

Copied: pypy/branch/2.5-merge/pypy/lib/test2/test_collections.py (from r58815, pypy/branch/2.5-merge/pypy/lib/app_test/test_collections.py)
==============================================================================
--- pypy/branch/2.5-merge/pypy/lib/app_test/test_collections.py	(original)
+++ pypy/branch/2.5-merge/pypy/lib/test2/test_collections.py	Wed Oct  8 15:02:23 2008
@@ -1,5 +1,5 @@
+from pypy.lib import collections
 import py
-import collections
 
 def test_deque_remove_empty():
     d = collections.deque([])
@@ -14,3 +14,10 @@
     d = collections.deque([MutatingCmp()])
     py.test.raises(IndexError, d.remove, 1)
     
+class SubclassWithKwargs(collections.deque):
+    def __init__(self, newarg=1):
+        collections.deque.__init__(self)
+
+def test_subclass_with_kwargs():
+    # SF bug #1486663 -- this used to erroneously raise a TypeError
+    SubclassWithKwargs(newarg=1)



More information about the Pypy-commit mailing list