new.instancemethod and new style classes

Pedro Rodriguez pedro_rodriguez at club-internet.fr
Tue Jan 22 10:39:08 CET 2002


"Mark McEahern" <mark at mceahern.com> wrote:

> The instancemethod of the new module does not work with new style
> classes:
> 
>   import new
> 
>   class fooOld:pass
>   class foo(object):pass
> 
>   def bar(self):
>     print "foobar"
> 
>   fooOld.bar = new.instancemethod(bar, None, fooOld) foo.bar =
>   new.instancemethod(bar, None, foo)
> 
> The last line generates this error:
> 
>   Traceback (most recent call last):
>     File "<stdin>", line 1, in ?
>   TypeError: instancemethod() argument 3 must be class, not type
> 
> Is this by design?
> 
> Thanks,
> 
> // mark
> 
> 

It has been fixed in CVS version of newmodule.c by Guido as bug
#503091, and worked for me. So I don't think it was left out by
design. No workaround that I know unfortunately.

New style classes is such an ambitious work that there may still
be some dark corners that miss this enlightment.
So "Go Out And Get 'Em Boy!" (Tommy - The Wedding Present) ;)

Regards,
-- 

Pedro



More information about the Python-list mailing list