[Pyobjc-dev] Passing NSError** from Obj-C to Python
Brought to you by:
ronaldoussoren
|
From: Ian B. <ia...@on...> - 2009-01-01 17:19:09
|
Hey folks,
I'm running into trouble with a feature/limitation of the PyObjC
bridge and could use help figuring out how to work around it. I am
currently implementing a Cocoa plugin in pure Python using PyObjC,
py2app, and the default Leopard Python frameworks. The application
I'm plugging into expects to be able to send this message to any
classes that I create:
- (BOOL)performActionWithContext:(id)context error:(NSError **)outError
Because NSError pointers don't translate directly to Python, I've
coded my class method as follows:
def performActionWithContext_error_(self, context):
Objective-C sends the message just fine, and the Python code executes
correctly (the application's document reflects the changes after I
activate the plugin). However, when I run it I get an uncaught
exception error ("Uncaught system exception: signal 11") and the
program crashes. Best I can tell, this is because of the NSError**
stuff. All the examples I can find about using NSError** talk about
calling functions that use it from Python, and handling the tuple
return with Python. I haven't been able to find any resources about
sending a message with NSError** from Objective-C to Python. Is there
something specific I need to do to get this working? Any suggestions
for how to debug the problem?
If I've got things set up the way they should be, please let me know
that, too. It's possible that this error is located in the
application itself, which is currently in early beta.
I've tried setting up various signatures for the method, accepting an
argument as a placeholder for the pointer, and so forth, but nothing
changes the uncaught system exception. For example:
@objc.signature('B@:@:^^@')
def performActionWithContext_error_(self, context, outError):
Works identically to the version lacking the outError argument, as
does this:
@objc.signature('B@:@@')
def performActionWithContext_error_(self, context, outError):
Thanks for any pointers you can give me! (Sorry, couldn't resist the
pun.)
Ian
|