MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / runStringObject

Method runStringObject

src/Base/Interpreter.cpp:317–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317Py::Object InterpreterSingleton::runStringObject(const char* sCmd)
318{
319 PyObject* module {};
320 PyObject* dict {};
321 PyObject* presult {};
322
323 PyGILStateLocker locker;
324 module = PP_Load_Module("__main__"); /* get module, init python */
325 if (!module) {
326 throw PyException(); /* not incref'd */
327 }
328 dict = PyModule_GetDict(module); /* get dict namespace */
329 if (!dict) {
330 throw PyException(); /* not incref'd */
331 }
332
333
334 presult = PyRun_String(sCmd, Py_eval_input, dict, dict); /* eval direct */
335 if (!presult) {
336 if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
337 throw SystemExitException();
338 }
339
340 throw PyException();
341 }
342
343 return Py::asObject(presult);
344}
345
346void InterpreterSingleton::systemExit()
347{

Callers 2

onCameraChangedMethod · 0.80
PyMOD_INIT_FUNCFunction · 0.80

Calls 3

PP_Load_ModuleFunction · 0.85
PyExceptionFunction · 0.85
SystemExitExceptionFunction · 0.85

Tested by

no test coverage detected