Commit 5e1d9f08 authored by Jim Fulton's avatar Jim Fulton

Fixed bug in Base __getattro__ that caused __of__ to be missed in

instances of instances of subclasses (meta classes) of ExtensionClass.
parent 185f41fd
......@@ -142,7 +142,8 @@ Base_getattro(PyObject *obj, PyObject *name)
If the tp_descr_get of res is of_get,
then call it. */
if (res->ob_type->ob_type == &ExtensionClassType
if (PyObject_TypeCheck(res->ob_type,
&ExtensionClassType)
&& res->ob_type->tp_descr_get != NULL)
res = res->ob_type->tp_descr_get(
res, obj,
......
......@@ -709,6 +709,34 @@ def test_inheriting___doc__():
"""
def test___of___w_metaclass_instance():
"""When looking for extension class instances, need to handle meta classes
>>> class C(Base):
... pass
>>> class O(Base):
... def __of__(self, parent):
... print '__of__ called on an O'
>>> class M(ExtensionClass):
... pass
>>> class X:
... __metaclass__ = M
...
>>> class S(X, O):
... pass
>>> c = C()
>>> c.s = S()
>>> c.s
__of__ called on an O
"""
from doctest import DocTestSuite
import unittest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment