[Python-3000] special attrs looked up on the type, not instance (original) (raw)
Neal Norwitz nnorwitz at gmail.com
Wed Mar 14 04:19:23 CET 2007
- Previous message: [Python-3000] Octal
- Next message: [Python-3000] __special__ attrs looked up on the type, not instance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
---------- 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 dirobject() + PyObject * dirfunc = PyObjectGetAttrString((PyObject*)obj->obtype, + "dir"); Shouldn't the first arg just be obj, not obj->obtype?
[Georg] This is modeled after the principle that for new-style objects, special methods are looked up on the type, not the instance.
- I didn't remember this, do we have it documented somewhere?
- Assuming #1 is correct, is this rule consistently applied?
- How does (should) this affect 2.6 and migration to 3.0, if at all?
n
- Previous message: [Python-3000] Octal
- Next message: [Python-3000] __special__ attrs looked up on the type, not instance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]