@@ -13,7 +13,7 @@ inline pybind11::module pyobject_from_gobj(gpointer ptr){
1313 return pybind11::module (Py_None, false );
1414}
1515
16- PythonInterpreter::PythonInterpreter (){
16+ Python::Interpreter::Interpreter (){
1717 auto init_juci_api=[](){
1818 pybind11::module (pygobject_init (-1 ,-1 ,-1 ),false );
1919 pybind11::module api (" jucpp" ," Python bindings for juCi++" );
@@ -52,26 +52,29 @@ PythonInterpreter::PythonInterpreter(){
5252 add_path (Config::get ().python .site_packages );
5353 add_path (plugin_path);
5454 Py_Initialize ();
55+ long unsigned size = 0L ;
56+ argv=Py_DecodeLocale (" " ,&size);
57+ PySys_SetArgv (0 ,&argv);
5558 boost::filesystem::directory_iterator end_it;
5659 for (boost::filesystem::directory_iterator it (plugin_path);it!=end_it;it++){
5760 auto module_name=it->path ().stem ().string ();
5861 if (module_name!=" __pycache__" ){
5962 auto module =import (module_name);
6063 if (!module )
61- std::cerr << std::string (PythonError ()) << std::endl;
64+ std::cerr << std::string (Error ()) << std::endl;
6265 }
6366 }
6467}
6568
66- pybind11::module PythonInterpreter ::get_loaded_module (const std::string &module_name){
69+ pybind11::module Python::Interpreter ::get_loaded_module (const std::string &module_name){
6770 return pybind11::module (PyImport_AddModule (module_name.c_str ()), true );
6871}
6972
70- pybind11::module PythonInterpreter ::import (const std::string &module_name){
73+ pybind11::module Python::Interpreter ::import (const std::string &module_name){
7174 return pybind11::module (PyImport_ImportModule (module_name.c_str ()), false );
7275}
7376
74- void PythonInterpreter ::add_path (const boost::filesystem::path &path){
77+ void Python::Interpreter ::add_path (const boost::filesystem::path &path){
7578 std::wstring sys_path (Py_GetPath ());
7679 if (!sys_path.empty ())
7780#ifdef _WIN32
@@ -83,15 +86,15 @@ void PythonInterpreter::add_path(const boost::filesystem::path &path){
8386 Py_SetPath (sys_path.c_str ());
8487}
8588
86- PythonInterpreter::~PythonInterpreter (){
87- auto err=PythonError ();
89+ Python::Interpreter::~Interpreter (){
90+ auto err=Error ();
8891 if (Py_IsInitialized ())
8992 Py_Finalize ();
9093 if (err)
9194 std::cerr << std::string (err) << std::endl;
9295}
9396
94- PythonError::PythonError (){
97+ Python::Error::Error (){
9598 pybind11::object error (PyErr_Occurred (), false );
9699 if (error){
97100 PyObject *exception,*value,*traceback;
@@ -107,10 +110,10 @@ PythonError::PythonError(){
107110 }
108111}
109112
110- PythonError ::operator std::string (){
113+ Python::Error ::operator std::string (){
111114 return exp + " \n " + val + " \n " + trace;
112115}
113116
114- PythonError ::operator bool (){
117+ Python::Error ::operator bool (){
115118 return !exp.empty ();
116119}
0 commit comments