[Pyobjc-dev] Strange PyObjC behavior
Brought to you by:
ronaldoussoren
|
From: Artem Y <ya...@ym...> - 2009-12-16 10:27:22
|
Hi All,
I'm writing simple PyObjC application and I faced strange problem. I do development on 10.6 using Xcode (10.5 Base SDK) and also test it on my other 10.5 Mac. Everything works well on my machines, but some users complains, for example, I was using NSFormatters, this formatter worked fine on both of my machines:
class MyFormatter(NSFormatter):
def stringForObjectValue_(self, val):
return str(val)
def getObjectValue_forString_errorDescription_(self, v):
return (True, formatingFunction(v), None)
but I received complains from users, their crash report said "class MyFormatter(NSFormatter): objc.BadPrototypeError: Objective-C expects 4 arguments, Python argument has 2 arguments for ", but they were using 10.6.2 and their objc.__version__ was '2.2b3', same as on my 10.6 machine. It's obvious that "getObjectValue_forString_errorDescription_" should take 4 arguments(including self) but it didn't work with 4 arguments on my machine. I just get rid of NSFormatters to solve this issue.
The other thing, I needed to add Growl support, I created this wrapper:
class GrowlWrapper(NSObject):
def init(self, name):
self = super(GrowlWrapper, self).init()
self.name = name
objc.loadBundle("GrowlApplicationBridge", globals(),
bundle_path=objc.pathForFramework(os.path.dirname(sys.argv[0]) + '/../Frameworks/Growl.framework'))
self._growl = GrowlApplicationBridge
self._growl.setGrowlDelegate_(self)
return self
def notify(self, title, description):
self._growl.notifyWithTitle_description_notificationName_iconData_priority_isSticky_clickContext_(title,
description, self.name,None,
0,False,NSDate.date())
As usual everything was ok on my machines, but other users had problems, their crash report complained that GrowlWrapper.init takes 2 arguments instead of 1. I deleted additional argument - program didn't crash and worked fine except that it didn't show Growl popup, no messages on Console, however on my machines new GrowlWrapper worked fine. And right now I don't have any clue how to fix it.
How could all this happen if OS X versions and objc.__version__ are the same ?
My program released under GPL and is quite simple, I'd appreciate if someone could test it out and see what's wrong.
Many thanks,
Artem
|