---------- Forwarded message from python-3000-checkins ---------- Neal Norwitz schrieb: > I assume this is not the desired behaviour? > >>>> class F: > ... def __dir__(self): > ... return [5] > ... >>>> dir(F()) > [5] >>>> f = F() >>>> dir(f) > [5] >>>> def __dir__(): return [10] > ... >>>> f.__dir__ = __dir__ >>>> dir(f) > [5] > > I think the problem is in _dir_object() > > + PyObject * dirfunc = PyObject_GetAttrString((PyObject*)obj->ob_type, > + "__dir__"); > > Shouldn't the first arg just be obj, not obj->ob_type?
[Georg] This is modeled after the principle that for new-style objects, __special__ methods are looked up on the type, not the instance. ----- 1) I didn't remember this, do we have it documented somewhere? 2) Assuming #1 is correct, is this rule consistently applied? 3) How does (should) this affect 2.6 and migration to 3.0, if at all? n _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com