[Pyobjc-dev] OC_PythonObject broken
Brought to you by:
ronaldoussoren
From: Steven D. M. <sd...@mi...> - 2000-12-20 21:44:41
|
It looks like the mailings list is working -- with some delay -- as long as I post from the machine I'm subscribed under. ( and since my mac gets a random address & number depending on where I hook it up to the network, I can't mail from there. ) Although I'm one of the project admins, I'm pretty new to both objective-c and the pyobjc module, but since a lot of the revived interest has been sparked by Mac-OSX, I'm sure there are others out there trying to learn their way around the code. It looks like OC_PythonObject is broken. OC_PythonObject is the bridge between python objects and objective-c objects that implements the NSProxy abstract class and redirects method calls to it's python methods. ( For example, this would be how you would subclass NSApplication in Python to make an AppKit application.) There are a number of things in PyObjC.runtime that you can't touch: ObjC.lookup_class( 'OC_PythonObject' ) for example, dies with: Dec 19 18:19:37 python[435] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSProxy forwardInvocation:] called! This appears to be the line that crashes: if (obj && ([obj isKindOfClass: [NSAutoreleasePool class]] == NO) ) OC_PythonObject's have define an instance method - (void)forwardInvocation:(NSInvocation *)anInvocation; to do this forwarding, but there's no class method, so isKindOfClass: on the class object causes the crash. I did a quick patch to try to follow this further: PythonObject.m 246,253d245 < + (void)forwardInvocation:(NSInvocation *)anInvocation; < { < printf( "%s\n" , [[anInvocation description] cString] ); < [anInvocation setTarget: [NSObject class]]; < [anInvocation invoke]; < return; < } < with that, I can access ObjC.runtime.OC_PythonObject without crashing. However, accessing it's method dies: >>> rt.OC_PythonObject.newWithObject_ Dec 20 15:53:57 python[407] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSProxy methodSignatureForSelector:] called! This was actually pretty expected, as forwardInvocation and methodSignatureForSelector are documented as the two methods you MUST override in a concrete NSProxy class. A few other objects in the runtime will cause a crash. I made a little script to iterate thru the __objc_classes__ and added them to a skiplist until I could get thru the whole runtime. They are: SkipList = ('NSProxy', 'NSConcreteProtocolChecker', 'NSDistantObject', 'NSInvocationBuilder', 'NSMutableStringProxy' , 'NSProtocolChecker' , '_NSZombie' ) -- Steve Majewski <sdm7g@Virginia.EDU> |