[Pyobjc-dev] DeprecationWarning: Not all Objective-C arguments are present in the Python argument-l
Brought to you by:
ronaldoussoren
|
From: James R E. <ea...@cc...> - 2008-02-20 06:00:12
|
I've been using the following decorator in PyObjC 1.4 without
problems, but now PyObjC 2.0 gives me a nice DeprecationWarning. Am I
doing something naughty and/or dangerous? If so, is there a safer way
to accomplish the same thing in PyObjC2?
First, the decorator:
def trap_exceptions(func):
''' Trap exceptions and prevent them from being passed along to
the ObjC runtime. '''
def trapper(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except:
sys.stderr.write('Exception in %s: ' % (func.__name__))
traceback.print_exception(*sys.exc_info())
return trapper
Typical usage is on an Objective-C entrypoint. e.g.:
@trap_exceptions
def performDragOperation_(self, sender):
if self.delegate is not None \
and
self.delegate.respondsToSelector_('performDragOperation:'):
return self.delegate.performDragOperation_(sender)
return False
This worked fine pre-Leopard. When an exception was thrown somewhere
in (e.g.) performDragOperation_, I'd get a stack trace on the console
and everything would carry along as if nothing happened. In PyObjC2,
the decorator appears to behave as expected, but I also get this
warning for every @trap_exceptions'ed method (at NIB load time):
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/
python/PyObjC/PyObjCTools/NibClassBuilder.py:219: DeprecationWarning:
Not all Objective-C arguments are present in the Python argument-list
of <unbound selector observeValueForKeyPath:ofObject:change:context:
of CBIconView at 0x4f1fef0>
return metaClass(name, bases, methods)
Thanks!
James
PS: Thanks for all the work you've done on PyObjC 2.0. There are
lots of wonderful improvements here! I'm very much looking forward to
the Tiger backport. :-)
--
Doctors are sadists who like to play God and watch lesser people scream
-- Bren MacGuff in "Juno"
|