From 94e55d70c07d419f8d4268ea69321ddb6e39fd74 Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 14 Jul 2006 14:08:12 +0000 Subject: [PATCH] Additional checks for correct executing script GraphErr_Msgs.py (see PAL 12865). --- .../DataFlowExecutor_PyDynInvoke.cxx | 136 ++++++++++-------- 1 file changed, 78 insertions(+), 58 deletions(-) diff --git a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx index 16f902b..fd0acdc 100644 --- a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx @@ -263,7 +263,7 @@ extern "C" PyObject * PyRunMethod( PyObject * dummy , PyObject * Args ) { return Result ; } -#define PyDynInvokeTrace 1 +#define PyDynInvokeTrace 0 bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , const char *method , ServicesAnyData * InParametersList , int nInParams , @@ -523,7 +523,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , else { ArgValue = Result ; } - if ( !PyInt_Check( ArgValue ) ) { + if ( !ArgValue || !PyInt_Check( ArgValue ) ) { cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (boolean)" << endl ; RetVal = false ; } @@ -532,9 +532,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , } data <<= (CORBA::Any::from_boolean ) b ; #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << b << " (boolean)" - << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" - << ArgValue->ob_refcnt << endl ; + if ( ArgValue ) + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << b << " (boolean)" + << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" + << ArgValue->ob_refcnt << endl ; #endif break ; } @@ -550,7 +551,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , //JR 04.04.2005 Debug if ( !PyInt_Check( ArgValue ) ) { //Difficult to understand that behavior ... Python char type is a string of length 1 ! // or type is int ... - if ( !PyString_Check( ArgValue ) && !PyInt_Check( ArgValue ) ) { + if ( !ArgValue || !PyString_Check( ArgValue ) && !PyInt_Check( ArgValue ) ) { cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (char)" << endl ; RetVal = false ; } @@ -559,9 +560,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , } data <<= (CORBA::Any::from_char ) c ; #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << c << " (char)" - << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" - << ArgValue->ob_refcnt << endl ; + if ( ArgValue ) + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << c << " (char)" + << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" + << ArgValue->ob_refcnt << endl ; #endif break ; } @@ -574,7 +576,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , else { ArgValue = Result ; } - if ( !PyInt_Check( ArgValue ) ) { + if ( !ArgValue || !PyInt_Check( ArgValue ) ) { cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (short)" << endl ; RetVal = false ; } @@ -583,9 +585,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , } data <<= s ; #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << s << " (short)" - << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" - << ArgValue->ob_refcnt << endl ; + if ( ArgValue ) + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << s << " (short)" + << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" + << ArgValue->ob_refcnt << endl ; #endif break ; } @@ -598,10 +601,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , else { ArgValue = Result ; } - if ( PyLong_Check( ArgValue ) ) { + if ( ArgValue && PyLong_Check( ArgValue ) ) { l = PyLong_AsLong( ArgValue ) ; } - else if ( PyInt_Check( ArgValue ) ) { + else if ( ArgValue && PyInt_Check( ArgValue ) ) { l = PyInt_AsLong( ArgValue ) ; } else { @@ -610,9 +613,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , } data <<= l ; #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << l << " (long)" - << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" - << ArgValue->ob_refcnt << endl ; + if ( ArgValue ) + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << l << " (long)" + << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" + << ArgValue->ob_refcnt << endl ; #endif break ; } @@ -625,25 +629,31 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , else { ArgValue = Result ; } - if ( !PyFloat_Check( ArgValue ) ) { - // mkr : bug PAL12454 - if ( PyLong_Check( ArgValue ) ) { - cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (long)" << endl ; - long l = PyLong_AsLong( ArgValue ); - f = (float) l; - } - else if ( PyInt_Check( ArgValue ) ) { - cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (int)" << endl ; - long l = PyInt_AsLong( ArgValue ); - f = (float) l; + if ( ArgValue ) { + if ( !PyFloat_Check( ArgValue ) ) { + // mkr : bug PAL12454 + if ( PyLong_Check( ArgValue ) ) { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (long)" << endl ; + long l = PyLong_AsLong( ArgValue ); + f = (float) l; + } + else if ( PyInt_Check( ArgValue ) ) { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (int)" << endl ; + long l = PyInt_AsLong( ArgValue ); + f = (float) l; + } + else { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ; + RetVal = false ; + } } else { - cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ; - RetVal = false ; + f = PyFloat_AsDouble( ArgValue ) ; } } - else { - f = PyFloat_AsDouble( ArgValue ) ; + else { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ; + RetVal = false ; } #ifdef REDHAT // mkr : debug for PAL12255 data <<= f ; @@ -651,9 +661,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , data.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f)); #endif #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << f << " (float)" - << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" - << ArgValue->ob_refcnt << endl ; + if ( ArgValue ) + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << f << " (float)" + << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" + << ArgValue->ob_refcnt << endl ; #endif break ; } @@ -666,25 +677,31 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , else { ArgValue = Result ; } - if ( !PyFloat_Check( ArgValue ) ) { - // mkr : bug PAL12454 - if ( PyLong_Check( ArgValue ) ) { - cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (long)" << endl ; - long l = PyLong_AsLong( ArgValue ); - d = (double) l; - } - else if ( PyInt_Check( ArgValue ) ) { - cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (int)" << endl ; - long l = PyInt_AsLong( ArgValue ); - d = (double) l; + if ( ArgValue ) { + if ( !PyFloat_Check( ArgValue ) ) { + // mkr : bug PAL12454 + if ( PyLong_Check( ArgValue ) ) { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (long)" << endl ; + long l = PyLong_AsLong( ArgValue ); + d = (double) l; + } + else if ( PyInt_Check( ArgValue ) ) { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " OK (int)" << endl ; + long l = PyInt_AsLong( ArgValue ); + d = (double) l; + } + else { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ; + RetVal = false ; + } } else { - cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ; - RetVal = false ; + d = PyFloat_AsDouble( ArgValue ) ; } } - else { - d = PyFloat_AsDouble( ArgValue ) ; + else { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ; + RetVal = false ; } #ifdef REDHAT // mkr : debug for PAL12255 data <<= d ; @@ -692,9 +709,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , data.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d)); #endif #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << d << " (double)" - << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" - << ArgValue->ob_refcnt << endl ; + if ( ArgValue ) + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << d << " (double)" + << " Result->ob_refcnt" << Result->ob_refcnt << " ArgValue->ob_refcnt" + << ArgValue->ob_refcnt << endl ; #endif break ; } @@ -708,9 +726,10 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , ObjIor = Result ; } #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) " - << " Result->ob_refcnt" << Result->ob_refcnt << " ObjIor->ob_refcnt" - << ObjIor->ob_refcnt << endl ; + if ( ObjIor ) + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) " + << " Result->ob_refcnt" << Result->ob_refcnt << " ObjIor->ob_refcnt" + << ObjIor->ob_refcnt << endl ; #endif //Py_INCREF( ObjIor ) ; // PyObject_Print( ObjIor , stdout , 0 ) ; @@ -719,7 +738,8 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , //ResultIor = PyEvalCallObject( "PyObjIor" , MyPyObjIor , MyPyObjIorList ) ; ResultIor = PyObject_CallFunction( MyPyObjIor , "O",ObjIor ) ; #if PyDynInvokeTrace - cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ; + if ( ObjIor ) + cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ; #endif //Py_DECREF( ObjIor ) ; #if PyDynInvokeTrace -- 2.39.2