From: Anthony Geay Date: Thu, 19 Feb 2015 10:42:57 +0000 (+0100) Subject: Correction of bug when pyobj hides a pystring with foreach node. X-Git-Tag: V7_6_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d5175677a8442c34b6d63e9a28b007b32776af9;p=modules%2Fyacs.git Correction of bug when pyobj hides a pystring with foreach node. --- diff --git a/src/runtime/TypeConversions.cxx b/src/runtime/TypeConversions.cxx index 69a8a2a0a..740fe72a4 100644 --- a/src/runtime/TypeConversions.cxx +++ b/src/runtime/TypeConversions.cxx @@ -774,7 +774,7 @@ namespace YACS { static inline std::string convert(const TypeCode *t,PyObject* o,void*,int protocol) { - if (PyString_Check(o)) + if (PyString_Check(o) && strncmp(t->id(),"python",6)!=0) { // the objref is used by Python as a string (prefix:value) keep it as a string return PyString_AS_STRING(o); diff --git a/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py b/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py index 6400a034f..776905907 100644 --- a/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py +++ b/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py @@ -83,6 +83,52 @@ class StdAloneYacsLoaderTest1(unittest.TestCase): p.saveSchema("foreachImbrBuildFS.xml") pass + def test2(self): + """ Non regression test. When input/output declared as pyobj hiding a string type to go to or from a ForEachLoop it previous lead + to an error. + """ + fname="BugPyObjStrInYacs.xml" + p=self.r.createProc("pr") + tc0=p.createInterfaceTc("python:obj:1.0","pyobj",[]) + tc1=p.createSequenceTc("list[pyobj]","list[pyobj]",tc0) + # + node0=self.r.createScriptNode("Salome","node0") + node0.setScript("o1=[\"a\",\"bc\"]") + o1=node0.edAddOutputPort("o1",tc1) + p.edAddChild(node0) + # + node1=self.r.createForEachLoop("node1",tc0) + p.edAddChild(node1) + p.edAddCFLink(node0,node1) + node1.edGetNbOfBranchesPort().edInitInt(1) + p.edAddLink(o1,node1.edGetSeqOfSamplesPort()) + # + node10=self.r.createScriptNode("Salome","node10") + node10.setScript("o1=3*i1") + i10_1=node10.edAddInputPort("i1",tc0) + o10_1=node10.edAddOutputPort("o1",tc0) + node1.edAddChild(node10) + p.edAddLink(node1.edGetSamplePort(),i10_1) + # + node2=self.r.createScriptNode("Salome","node2") + node2.setScript("o1=i1") + i2_1=node2.edAddInputPort("i1",tc1) + o2_1=node2.edAddOutputPort("o1",tc1) + p.edAddChild(node2) + p.edAddCFLink(node1,node2) + p.edAddLink(o10_1,i2_1) + ## + p.saveSchema(fname) + p=self.l.load(fname) + ## + ex = pilot.ExecutorSwig() + self.assertEqual(p.getState(),pilot.READY) + ex.RunW(p,0) + self.assertEqual(p.getState(),pilot.DONE) + # + self.assertEqual(p.getChildByName("node2").getOutputPort("o1").get(),['aaa','bcbcbc']) + pass + def tearDown(self): del self.r del self.l