65 PyObject* builtins = PyImport_ImportModule(
"pcbnew" );
71 PyObject* globals = PyDict_New();
72 PyDict_SetItemString( globals,
"pcbnew", builtins );
73 Py_DECREF( builtins );
77 snprintf( cmd,
sizeof(cmd),
"result = %s()", aMethodName );
80 PyObject* localDict = PyDict_New();
81 PyObject* pobj = PyRun_String( cmd, Py_file_input, globals, localDict);
86 PyObject* str = PyDict_GetItemString(localDict,
"result" );
87 const char* str_res =
nullptr;
91 PyObject* temp_bytes = PyUnicode_AsEncodedString( str,
"UTF-8",
"strict" );
93 if( temp_bytes !=
nullptr )
95 str_res = PyBytes_AS_STRING( temp_bytes );
97 Py_DECREF( temp_bytes );
101 wxLogMessage( wxS(
"cannot encode Unicode python string" ) );
112 Py_DECREF( localDict );
114 if( PyErr_Occurred() )
116 if( strcmp( aMethodName,
"pcbnew.GetWizardsBackTrace" ) == 0 )
117 aNames = PyErrStringWithTraceback();
119 wxLogMessage( PyErrStringWithTraceback() );
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.