Salome HOME
[PYTHON 3] WIP
[modules/yacs.git] / src / runtime / RuntimeSALOME.cxx
index 31985cf2f7c8a706dbe86fe68fab83cf78ea44fc..d8f746fe56a7c54367a28b3a4a25c11be258bcbc 100644 (file)
@@ -287,14 +287,26 @@ void RuntimeSALOME::init(long flags, int argc, char* argv[])
           Py_InitializeEx(0); // do not install signal handlers
 #endif
           if (argc > 0 && argv != NULL)
-            PySys_SetArgv(argc, argv);
+            {
+              wchar_t **changed_argv = new wchar_t*[argc];
+              for (int i = 0; i < argc; i++)
+              {
+                changed_argv[i] = Py_DecodeLocale(argv[i], NULL);
+              }
+              PySys_SetArgv(argc, changed_argv);
+            } 
           else
             {
               int pyArgc = 1;
               char* pyArgv[1];
               char defaultName[] = "SALOME_YACS_RUNTIME";
+              wchar_t **changed_pyArgv = new wchar_t*[pyArgc];
               pyArgv[0] = defaultName;
-              PySys_SetArgv(pyArgc, pyArgv);
+              for (int i = 0; i < pyArgc; i++)
+              {
+                changed_pyArgv[i] = Py_DecodeLocale(pyArgv[i], NULL);
+              }
+              PySys_SetArgv(pyArgc, changed_pyArgv);
             }
           PyEval_InitThreads(); /* Create (and acquire) the interpreter lock (for threads)*/
           PyEval_SaveThread(); /* Release the thread state */
@@ -336,7 +348,7 @@ void RuntimeSALOME::init(long flags, int argc, char* argv[])
             {
               goto out;
             }
-          _api = (omniORBpyAPI*)PyCObject_AsVoidPtr(pyapi);
+          _api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
           Py_DECREF(pyapi);
 
           res=PyRun_String("\n"