Salome HOME
[EDF27816] : in case of UsingPythonCache disabled (default) all temporary variables...
[modules/yacs.git] / src / evalyfx / YACSEvalSessionInternal.cxx
index 09a1971c20ef14ea885e22ff6bd91e39ad8a4b33..4f71c0091d705acc545087daf1cb44c400486d46 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2012-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,7 @@
 #include "YACSEvalSession.hxx"
 
 #include "PyStdout.hxx"
-#include "AutoGIL.hxx"
+#include "PythonCppUtils.hxx"
 #include "Exception.hxx"
 
 YACSEvalSession::YACSEvalSessionInternal::YACSEvalSessionInternal():_orb(CORBA::ORB::_nil()),_sl(Engines::SalomeLauncher::_nil())
@@ -46,9 +46,13 @@ Engines::SalomeLauncher_var YACSEvalSession::YACSEvalSessionInternal::goFetching
   //
   const char methName[]="goFetchingSalomeLauncherInNS";
   const char fetchPyCmd[]="import salome,CORBA\nsalome.salome_init()\nsl=salome.naming_service.Resolve(\"/SalomeLauncher\")\nif not CORBA.is_nil(sl):\n  return salome.orb.object_to_string(sl)\nelse:\n  raise Exception(\"Impossible to locate salome launcher !\")";
-  YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(methName,fetchPyCmd));
-  YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
-  std::string ior(PyBytes_AsString(val));
+  AutoPyRef func(YACS::ENGINE::evalPy(methName,fetchPyCmd));
+  AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
+  std::string ior;
+  if (PyUnicode_Check(val))
+    ior = PyUnicode_AsUTF8(val);
+  else
+    throw YACS::Exception("goFetchingSalomeLauncherInNS: python call error. ");
   CORBA::Object_var obj(string_to_object(ior));
   if(CORBA::is_nil(obj))
     throw YACS::Exception("goFetchingSalomeLauncherInNS : fetched ior is NIL !");