[Pythonmac-SIG] Segmentation Fault with AppleScripting
Martina at Oefelein.de
Fri May 30 21:12:58 EDT 2003
> I'm writing a Mac OS X application in Python and trying to use
> AppleScripting to open a web location.
You can also do this without AppleScripting:
url = NSURL.URLWithString_("http://www.apple.com")
wsp = NSWorkspace.sharedWorkspace()
> However, I seem to be having trouble
> allocating and releasing the NSAppleScript class properly. Here is the
> problematic section of code:
> def openWebSite(self)
> strScript = 'open location "http://www.apple.com"'
> appleScript = NSAppleScript.alloc().initWithSource_(strScript)
> The result of calling this code is a Segmentation Fault. If I leave
> out the
> last line (appleScript.release()) then there does not seem to be a
> (though I think that would be a memory leak).
Remove the last line. PyObjC takes care of the ugly reference counting,
so you shouldn't have to call retain/release normally. If you call
appleScript.release(), the object will be released twice, hence the
BTW: There is a dedicated mailing list for PyObjC:
You might get a quicker reply if you post PyObjC-related questions
More information about the Pythonmac-SIG