new.instancemethod and new style classes

Alex Martelli aleax at aleax.it
Tue Jan 22 09:28:36 CET 2002


"Mark McEahern" <mark at mceahern.com> wrote in message
news:mailman.1011683911.18673.python-list at python.org...
> The instancemethod of the new module does not work with new style classes:
    ...
> Is this by design?

Currently, yes; function new_instancemethod in Modules\newmodule.c
deliberately uses the O! (type-checked) style of argument for its
third argument, demanding that it be of Py_ClassType.  Whether that
typecheck is actually _needed_ is less clear to me; new_instancemethod
just delegates, after checking args, to PyMethod_New in file
Objects\classobject.c, but it appears to me that PyMethod_New
can also be called (and is e.g. in Objects\funcobject.c) with
a third argument that is a type, not a classic-class.  So maybe
the type-check in new_instancemethod could be softened without
ill effects (but I don't understand it enough to be sure).


Alex








More information about the Python-list mailing list