[pypy-commit] pypy default: Test and fix: 'object' has an empty __init__ which we should not copy.

arigo noreply at buildbot.pypy.org
Tue Aug 20 14:21:57 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r66257:93521d0a62cf
Date: 2013-08-20 14:21 +0200
http://bitbucket.org/pypy/pypy/changeset/93521d0a62cf/

Log:	Test and fix: 'object' has an empty __init__ which we should not
	copy. (trying again)

diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -737,6 +737,8 @@
     """
     flatten = {}
     for base in inspect.getmro(M):
+        if base is object:
+            continue
         for key, value in base.__dict__.items():
             if key.startswith('__') and key.endswith('__'):
                 if key not in special_methods:
diff --git a/rpython/rlib/test/test_objectmodel.py b/rpython/rlib/test/test_objectmodel.py
--- a/rpython/rlib/test/test_objectmodel.py
+++ b/rpython/rlib/test/test_objectmodel.py
@@ -612,3 +612,12 @@
         import_from_mixin(M, special_methods=['__str__'])
     assert str(A()).startswith('<')
     assert str(B()) == "m!"
+
+    class M(object):
+        pass
+    class A(object):
+        def __init__(self):
+            self.foo = 42
+    class B(A):
+        import_from_mixin(M)
+    assert B().foo == 42


More information about the pypy-commit mailing list