]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix bug 1114776
authorAlex Martelli <aleaxit@gmail.com>
Sun, 6 Feb 2005 07:56:18 +0000 (07:56 +0000)
committerAlex Martelli <aleaxit@gmail.com>
Sun, 6 Feb 2005 07:56:18 +0000 (07:56 +0000)
Lib/copy.py
Lib/test/test_copy.py

index 95e30f5231cfec672955e29dbf7ce43646d68de3..7771ef03e8b6f125378ead75a262b65383f0e1a1 100644 (file)
@@ -62,8 +62,9 @@ except ImportError:
 
 __all__ = ["Error", "copy", "deepcopy"]
 
+import inspect
 def _getspecial(cls, name):
-    for basecls in cls.__mro__:
+    for basecls in inspect.getmro(cls):
         try:
             return basecls.__dict__[name]
         except:
index 3484fa77dd5e0c263318c05dcfeb7e443f72d233..8ad5c8511f32c2614e8446f6efb9f8277564170d 100644 (file)
@@ -222,6 +222,23 @@ class TestCopy(unittest.TestCase):
         x = C(23)
         self.assertEqual(copy.deepcopy(x), x)
 
+    def _nomro(self):
+        class C(type):
+            def __getattribute__(self, attr):
+                if attr == '__mro__':
+                    raise AttributeError, "What, *me*, a __mro__? Nevah!"
+                return super(C, self).__getattribute__(attr)
+        class D(object):
+            __metaclass__ = C
+        return D()
+
+    def test_copy_mro(self):
+        x = self._nomro()
+        y = copy.copy(x)
+
+    def test_deepcopy_mro(self):
+        x = self._nomro()
+        y = copy.deepcopy(x)
 
     # The deepcopy() method
     def test_deepcopy_basic(self):