Re: [Pyobjc-dev] Deprecation warnings turned into BadPrototypeError
Brought to you by:
ronaldoussoren
|
From: Luc H. <lu...@ho...> - 2008-04-14 12:18:15
|
On 14 avr. 08, at 12:52, Ronald Oussoren wrote:
> Maybe. The code is designed to trigger on definitions like this: def
> wrapper(*args, **kwds), which seems to be the most common way to
> define wrapping decorators. The intention is to avoid varargs
> declarations other than wrapping decorators.
>
> Do you use "def wrapper(*args):" instead?
Ah, no, but I use "def wrapper(self, *args, **kwargs):" to wrap methods.
Here's an example of breaking code:
# -- begin snippet --
from Foundation import NSObject
def decorator(meth):
def decorated(self, *args, **kwargs):
print "in decorator"
meth(self, *args, **kwargs)
return decorated
class Foo (NSObject):
@decorator
def foo(self):
print "in Foo.foo"
Foo.alloc().init().foo()
# -- end snippet --
Running this code gives:
"Traceback (most recent call last):
File "./test.py", line 11, in <module>
class Foo (NSObject):
objc.BadPrototypeError: Not all Objective-C arguments are present in
the Python argument-list of <unbound selector foo of Foo at 0x1ed2e90>"
--
Luc Heinrich - lu...@ho...
|