Re: [Pyobjc-dev] Class OC_PythonObject: no such selector: _cfTypeID
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2010-06-11 03:45:34
|
On 10 Jun, 2010, at 15:16, jon...@mu... wrote: > My ObjC app loads user generated PyObjC scripts using a Python NSObject subclass (see below) > In general, errors in the Python scripts are generating application level exceptions. > > For instance, consider the following source file Boo.py. > > def funcBoo(): > return result > > Dynamically loading Boo.py and calling funcBoo using the class below generates an ObjC NSException in the host app: > Class OC_PythonObject: no such selector: _cfTypeID > > Assigning a value to the result variable resolves the problem. > > Is there a way of determining or reporting the underlying Python issue that is causing the NSException? Ensure that the following gets called somewhere: import objc; objc.setVerbose(1) After that PyObjC will log all exceptions when they get translated from Python to ObjC. That said, the exception that you are getting is not what I'd expect. I'll have to create a standalone application using your launcher to check what's going on here. Ronald > > # py executor > from Foundation import * > from AppKit import * > > import imp > import sys > > class MGSPythonScriptExecutor(NSObject): > > @classmethod > def loadModuleAtPath_functionName_arguments_(self, path, func, args): > f = open(path) > try: > theResult = None > realfunc = None > taskObject = None > > # load code at path as a module > modBoo = imp.load_module('modBoo', f, path, (".py", "r", imp.PY_SOURCE)) > > try: > taskObject = modBoo.objBoo.alloc().init() > except: > taskObject = None > > # get function from object > if taskObject is not None: > > # get function > realfunc = getattr(taskObject, func, None) > > # get function from module > if realfunc is None: > # get function > realfunc = getattr(modBoo, func, None) > > # if we have a function than call it > if realfunc is not None: > > # call the function with our arguments > # we make a tuple from our list and then unpack it > theResult = realfunc(*tuple(args)) > > except Exception: > theResult = "exception in python script executor: ", sys.exc_info() > except: > theResult = "error in python script executor: ", sys.exc_info() > finally: > f.close() > > return theResult > > Regards > > Jonathan Mitchell > > Developer > Mugginsoft LLP > http://www.mugginsoft.com > > > > > > > > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |