From: Alex Martelli Date: Sun, 6 Feb 2005 07:56:18 +0000 (+0000) Subject: fix bug 1114776 X-Git-Tag: v2.3.5~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9fe6b412211ae62af97737f5d7e77131be37199b;p=thirdparty%2FPython%2Fcpython.git fix bug 1114776 --- diff --git a/Lib/copy.py b/Lib/copy.py index 95e30f5231cf..7771ef03e8b6 100644 --- a/Lib/copy.py +++ b/Lib/copy.py @@ -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: diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py index 3484fa77dd5e..8ad5c8511f32 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -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):