[Pyobjc-dev] Re: [Pyobjc-checkins] [PyObjC-svn] r1708 - in branches/selector-cleanup: . Lib/objc/tes
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2005-06-26 10:14:44
|
On 26-jun-2005, at 1:52, Bob Ippolito wrote: > > On Jun 25, 2005, at 6:28 PM, ron...@re... wrote: > > >> Author: ronaldoussoren >> Date: Sat Jun 25 17:28:03 2005 >> New Revision: 1708 >> >> Modified: >> branches/selector-cleanup/Lib/objc/test/test_subclass.py >> branches/selector-cleanup/Modules/objc/objc-class.m >> branches/selector-cleanup/NEWS.txt >> Log: >> - staticmethods are moved into the meta class to get the right >> behaviour >> [XXX: not 100% sure if this the correct, staticmethods are now >> no longer >> accessible through instances] >> - found an incompatibility: calls to super() in class methods >> should be >> changed in user code because class methods are now normal >> methods in >> the meta class. >> > > Would this work? > > def alloc(cls): > return super(cls, cls).alloc() No, for several reasons. First of all the first argument to super must be a constant, otherwise method chaining won't work. This is true for pure python code as wel. Secondly for normal methods the first argument must be the type of the second argument (that is ``isinstance(arg2, arg1)``). Things are different for ``classmethod`` instances, which is why the interface has changed: class methods used to be simular to ``classmethod`` instances but are now normal methods on the meta class. BTW. I don't think this a problem, I seldomly use class methods outside of the PyObjC unittests. Ronald |