Changeset 4038 for neercs/trunk/src/interpreter.c
- Timestamp:
- Nov 25, 2009, 4:07:46 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/interpreter.c
r4037 r4038 182 182 Py_Initialize(); 183 183 184 PyInit_neercs( );184 PyInit_neercs(sl); 185 185 186 186 return 0; … … 219 219 } 220 220 221 PyObject *pModule, *pName, *pFunc , *pValue;221 PyObject *pModule, *pName, *pFunc; 222 222 223 223 /* Module from which to call the function */ … … 236 236 if (pModule != NULL) 237 237 { 238 pFunc = PyObject_GetAttrString(pModule, sl->interpreter_props.command); 239 if (pFunc && PyCallable_Check(pFunc)) 238 PyObject *o = PyRun_String(sl->interpreter_props.command, Py_eval_input, PyModule_GetDict(pModule), NULL); 239 debug("py object is %p\n", o); 240 if(!o) 240 241 { 241 pValue = PyObject_CallObject(pFunc, NULL); 242 if (pValue != NULL) { 243 char *res = getStringFromPyObject(pValue); 244 sl->interpreter_props.output_res = res; 245 debug("py Result of call: %s\n", res); 246 Py_DECREF(pValue); 247 err = 2; 248 } 249 else { 250 Py_DECREF(pFunc); 251 Py_DECREF(pModule); 252 sl->interpreter_props.output_err = getPythonError(); 253 err = 1; 254 debug("py Call failed\n"); 255 goto end; 256 return 1; 257 } 242 sl->interpreter_props.output_err = getPythonError(); 243 err = 1; 258 244 } 259 245 else 260 246 { 261 sl->interpreter_props.output_err = getPythonError(); 247 debug("py res : %s\n", getStringFromPyObject(o)); 248 sl->interpreter_props.output_res = getStringFromPyObject(o); 262 249 err = 1; 263 debug("py Error 2\n");264 goto end;265 250 } 251 goto end; 252 266 253 } 267 254 else … … 299 286 PyErr_Fetch(&type, &value, &traceback); 300 287 301 char *etype = getStringFromPyObject(type);302 288 char *evalue = getStringFromPyObject(value); 303 289
Note: See TracChangeset
for help on using the changeset viewer.