Salome HOME
Improvement to idefix porting to py3.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 3 Oct 2018 13:16:57 +0000 (15:16 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 3 Oct 2018 13:16:57 +0000 (15:16 +0200)
src/evalyfx/YACSEvalSessionInternal.cxx
src/evalyfx/YACSEvalYFXPattern.cxx

index c67f1402fef99af9cb24d56b04930fce9eef81c5..bf66dc94ae09864626bcfaeaec761da4f72be12a 100644 (file)
@@ -48,17 +48,10 @@ Engines::SalomeLauncher_var YACSEvalSession::YACSEvalSessionInternal::goFetching
   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("");
+  std::string ior;
   if (PyUnicode_Check(val))
-  {
-    PyObject * temp_bytes = PyUnicode_AsEncodedString(val, "UTF-8", "strict"); // Owned reference
-    if (temp_bytes != NULL)
-    {
-      ior = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
-      Py_DECREF(temp_bytes);
-    }
-  }
-  if(ior == "")
+    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))
index 7324f50b69c144b0b7b4725773005e8d0be634eb..8cfdf6629ae3edece66b274077153e3520129e2d 100644 (file)
@@ -899,32 +899,16 @@ void YACSEvalYFXGraphGenCluster::generateGraph()
   //
   YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent));
   YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
-  _locSchemaFile="";
   if (PyUnicode_Check(val))
-  {
-    PyObject * temp_bytes = PyUnicode_AsEncodedString(val, "UTF-8", "strict"); // Owned reference
-    if (temp_bytes != NULL)
-    {
-      _locSchemaFile = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
-      Py_DECREF(temp_bytes);
-    }
-  }
-  if(_locSchemaFile == "")
+    _locSchemaFile = PyUnicode_AsUTF8(val);
+  else
     throw YACS::Exception("YACSEvalYFXGraphGenCluster::generateGraph: python call error. ");
 
   func=YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent2);
   val=YACS::ENGINE::evalFuncPyWithNoParams(func);
-  _jobName="";
   if (PyUnicode_Check(val))
-  {
-    PyObject * temp_bytes = PyUnicode_AsEncodedString(val, "UTF-8", "strict"); // Owned reference
-    if (temp_bytes != NULL)
-    {
-      _jobName = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
-      Py_DECREF(temp_bytes);
-    }
-  }
-  if(_jobName == "")
+    _jobName = PyUnicode_AsUTF8(val);
+  else
     throw YACS::Exception("YACSEvalYFXGraphGenCluster::generateGraph: python call error. ");
 
   class ClusterPatcher : public YACSEvalYFXGraphGen::CustomPatcher