Re: [Pyobjc-dev] Running tests in one python session
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-05-29 21:12:22
|
On Thursday, May 29, 2003, at 22:53 Europe/Amsterdam, Jack Jansen wrote: > > On donderdag, mei 29, 2003, at 21:02 Europe/Amsterdam, Ronald Oussoren > wrote: >> Posing also introduces another, possibly more serious, problem: If >> someone poses as NSObject after you import Foundation, >> Foundation.NSObject still references the original NSObject (which is >> now %NSObject). This can be fixed for 'import Foundation', but not >> for 'from Foundation import *'. Sadly enough the latter is how most >> peoply import the module. > > I thought about this for a while, and I can't see why this is a > python-specific problem. If posing modifies the ObjC NSObject in-place > then the Python wrapper would see the changes. If posing modifies it > out-of-place then ObjC problems should also have the problem that any > references to NSObject created before the posing will still refer to > the old one. > > Or am I missing something (I assume I am, I just don't see it:-)? It's not the created objects, but the class itself. Objective-C: [SomeClass poseAs:[NSObject class]]; o = [[NSObject alloc] init]; o is now actually an instance of SomeClass. If you do cls=objc.lookUpClass('NSObject') in Python (which is basically what the Foundation module does) you get a pointer to a class structure. This structure is not changed when someone calls poseAs, and therefore 'cls' refers to the previous version of NSObject, that is now called '%NSObject'. Which means you never really get to see the effects of the call to poseAs. Ronald |