-// 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
#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())
//
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 !");