[pypy-commit] pypy win64-stage1: Merge with default

ctismer noreply at buildbot.pypy.org
Tue Dec 6 18:27:26 CET 2011


Author: Christian Tismer <tismer at stackless.com>
Branch: win64-stage1
Changeset: r50216:7c2b76526385
Date: 2011-12-06 18:26 +0100
http://bitbucket.org/pypy/pypy/changeset/7c2b76526385/

Log:	Merge with default

diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -406,7 +406,7 @@
             recurse.remove(id(self))
 
     def copy(self):
-        return type(self)(self, default_factory=self.default_factory)
+        return type(self)(self.default_factory, self)
     
     def __copy__(self):
         return self.copy()
diff --git a/pypy/module/_collections/app_defaultdict.py b/pypy/module/_collections/app_defaultdict.py
--- a/pypy/module/_collections/app_defaultdict.py
+++ b/pypy/module/_collections/app_defaultdict.py
@@ -38,7 +38,7 @@
             recurse.remove(id(self))
 
     def copy(self):
-        return type(self)(self, default_factory=self.default_factory)
+        return type(self)(self.default_factory, self)
     
     def __copy__(self):
         return self.copy()
diff --git a/pypy/module/_collections/test/test_defaultdict.py b/pypy/module/_collections/test/test_defaultdict.py
--- a/pypy/module/_collections/test/test_defaultdict.py
+++ b/pypy/module/_collections/test/test_defaultdict.py
@@ -38,3 +38,22 @@
         from _collections import defaultdict
         d = defaultdict(default_factory=5)
         assert d.keys() == ['default_factory']
+
+    def test_copy(self):
+        import _collections
+        def f():
+            return 42
+        d = _collections.defaultdict(f, {2: 3})
+        #
+        d1 = d.copy()
+        assert type(d1) is _collections.defaultdict
+        assert len(d1) == 1
+        assert d1[2] == 3
+        assert d1[3] == 42
+        #
+        import copy
+        d2 = copy.deepcopy(d)
+        assert type(d2) is _collections.defaultdict
+        assert len(d2) == 1
+        assert d2[2] == 3
+        assert d2[3] == 42
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -184,7 +184,8 @@
         n_new_elems_used = 1
         oldI = -1
         n_old_elems_to_use = old_shape[-1]
-        for s in new_shape[::-1]:
+        for i in range(len(new_shape) - 1, -1, -1):
+            s = new_shape[i]
             new_strides.insert(0, cur_step * n_new_elems_used)
             n_new_elems_used *= s
             while n_new_elems_used > n_old_elems_to_use:
diff --git a/pypy/module/test_lib_pypy/test_collections.py b/pypy/module/test_lib_pypy/test_collections.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/test_collections.py
@@ -0,0 +1,27 @@
+
+"""
+Extra tests for the pure Python PyPy _collections module
+(not used in normal PyPy's)
+"""
+
+from pypy.conftest import gettestobjspace
+
+class AppTestcStringIO:
+    def test_copy(self):
+        import _collections
+        def f():
+            return 42
+        d = _collections.defaultdict(f, {2: 3})
+        #
+        d1 = d.copy()
+        assert type(d1) is _collections.defaultdict
+        assert len(d1) == 1
+        assert d1[2] == 3
+        assert d1[3] == 42
+        #
+        import copy
+        d2 = copy.deepcopy(d)
+        assert type(d2) is _collections.defaultdict
+        assert len(d2) == 1
+        assert d2[2] == 3
+        assert d2[3] == 42


More information about the pypy-commit mailing list