From: ageay Date: Wed, 22 May 2013 06:18:45 +0000 (+0000) Subject: When NULL is returned as pointer of non instanciable class no more raise in python... X-Git-Tag: V6_main_FINAL~79 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5b6bb10848ab47751ba7c3451a2af1079d6d03b2;p=tools%2Fmedcoupling.git When NULL is returned as pointer of non instanciable class no more raise in python but Py_None returned. --- diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index e4db8f607..54597d51b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -583,6 +583,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(not fieldOnNodes1.isEqual(fieldOnCells1,1e-12,1e-15)); # fieldOnCells2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + self.assertEqual(fieldOnCells2.getMesh(),None) # to check that convertMesh wrapping do not raise but return Py_None self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); fieldOnCells1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index f505246a4..9d3a75684 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -409,6 +409,11 @@ PyObject *ToNumPyArray(MCData *self, int npyObjectType, const char *MCDataStr) static PyObject *convertMesh(ParaMEDMEM::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!mesh) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(mesh)) ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner); if(dynamic_cast(mesh)) @@ -425,6 +430,11 @@ static PyObject *convertMesh(ParaMEDMEM::MEDCouplingMesh *mesh, int owner) throw static PyObject *convertFieldDiscretization(ParaMEDMEM::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!fd) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(fd)) ret=SWIG_NewPointerObj(reinterpret_cast(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationP0,owner); if(dynamic_cast(fd)) @@ -443,6 +453,11 @@ static PyObject *convertFieldDiscretization(ParaMEDMEM::MEDCouplingFieldDiscreti static PyObject *convertDataArrayChar(ParaMEDMEM::DataArrayChar *dac, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!dac) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(dac)) ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,owner); if(dynamic_cast(dac)) @@ -455,6 +470,11 @@ static PyObject *convertDataArrayChar(ParaMEDMEM::DataArrayChar *dac, int owner) static PyObject *convertDataArray(ParaMEDMEM::DataArray *dac, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!dac) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(dac)) ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,owner); if(dynamic_cast(dac)) @@ -471,6 +491,11 @@ static PyObject *convertDataArray(ParaMEDMEM::DataArray *dac, int owner) throw(I static PyObject* convertMultiFields(ParaMEDMEM::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!mfs) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(mfs)) ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldOverTime,owner); else diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 07e3cedb4..bf3253cdd 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -39,6 +39,9 @@ extern med_geometry_type typmai3[32]; using namespace ParaMEDMEM; +const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64"; +const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32"; + MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName) { return new MEDFileFieldLoc(fid,locName); @@ -3350,6 +3353,67 @@ void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::Normal //= MEDFileAnyTypeField1TSWithoutSDA +/*! + * Prints a string describing \a this field into a stream. This string is outputted + * by \c print Python command. + * \param [in] bkOffset - number of white spaces printed at the beginning of each line. + * \param [in,out] oss - the out stream. + * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny + * info id printed, else, not. + */ +void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const +{ + std::string startOfLine(bkOffset,' '); + oss << startOfLine << "Field "; + if(bkOffset==0) + oss << "[Type=" << getTypeStr() << "] "; + oss << "on One time Step "; + if(f1tsId>=0) + oss << "(" << f1tsId << ") "; + oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl; + oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl; + const DataArray *arr=getUndergroundDataArray(); + if(arr) + { + const std::vector &comps=arr->getInfoOnComponents(); + if(f1tsId<0) + { + oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl; + oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl; + for(std::vector::const_iterator it=comps.begin();it!=comps.end();it++) + oss << startOfLine << " - \"" << (*it) << "\"" << std::endl; + } + if(arr->isAllocated()) + { + oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl; + } + else + oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl; + } + else + { + oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl; + } + oss << startOfLine << "----------------------" << std::endl; + if(!_field_per_mesh.empty()) + { + int i=0; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++) + { + const MEDFileFieldPerMesh *cur=(*it2); + if(cur) + cur->simpleRepr(bkOffset,oss,i); + else + oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl; + } + } + else + { + oss << startOfLine << "Field is not defined on any meshes !" << std::endl; + } + oss << startOfLine << "----------------------" << std::endl; +} + MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):_iteration(iteration),_order(order),_csit(csit) { } @@ -4234,64 +4298,6 @@ MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos); } -/*! - * Prints a string describing \a this field into a stream. This string is outputted - * by \c print Python command. - * \param [in] bkOffset - number of white spaces printed at the beginning of each line. - * \param [in,out] oss - the out stream. - * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny - * info id printed, else, not. - */ -void MEDFileField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const -{ - std::string startOfLine(bkOffset,' '); - oss << startOfLine << "Field on One time Step "; - if(f1tsId>=0) - oss << "(" << f1tsId << ") "; - oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl; - oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl; - const DataArrayDouble *arr=_arr; - if(arr) - { - const std::vector &comps=arr->getInfoOnComponents(); - if(f1tsId<0) - { - oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl; - oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl; - for(std::vector::const_iterator it=comps.begin();it!=comps.end();it++) - oss << startOfLine << " - \"" << (*it) << "\"" << std::endl; - } - if(arr->isAllocated()) - { - oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl; - } - else - oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl; - } - else - { - oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl; - } - oss << startOfLine << "----------------------" << std::endl; - if(!_field_per_mesh.empty()) - { - int i=0; - for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++) - { - const MEDFileFieldPerMesh *cur=(*it2); - if(cur) - cur->simpleRepr(bkOffset,oss,i); - else - oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl; - } - } - else - { - oss << startOfLine << "Field is not defined on any meshes !" << std::endl; - } - oss << startOfLine << "----------------------" << std::endl; -} - /*! * Returns all attributes and values of parts of \a this field lying on a given mesh. * Each part differs from other ones by a type of supporting mesh entity. The _i_-th @@ -4367,6 +4373,11 @@ DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() cons return 0; } +const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception) +{ + return TYPE_STR; +} + /*! * Returns a pointer to the underground DataArrayDouble instance. So the * caller should not decrRef() it. This method allows for a direct access to the field @@ -4522,6 +4533,11 @@ MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName arr->setInfoAndChangeNbOfCompo(infos); } +const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception) +{ + return TYPE_STR; +} + /*! * Returns a pointer to the underground DataArrayInt instance. So the * caller should not decrRef() it. This method allows for a direct access to the field @@ -4597,19 +4613,6 @@ DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::v return getUndergroundDataArrayInt(); } -/*! - * Prints a string describing \a this field into a stream. This string is outputted - * by \c print Python command. - * \param [in] bkOffset - number of white spaces printed at the beginning of each line. - * \param [in,out] oss - the out stream. - * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny - * info id printed, else, not. - */ -void MEDFileIntField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const -{ - // to implement (to factorize) -} - MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception) { return new MEDFileIntField1TSWithoutSDA(*this); @@ -6218,7 +6221,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::setName(const char *name) void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const { std::string startLine(bkOffset,' '); - oss << startLine << "Field multi time steps"; + oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]"; if(fmtsId>=0) oss << " (" << fmtsId << ")"; oss << " has the following name: \"" << _name << "\"." << std::endl; @@ -6689,6 +6692,11 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWit return new MEDFileField1TSWithoutSDA; } +const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception) +{ + return MEDFileField1TSWithoutSDA::TYPE_STR; +} + MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception) { return new MEDFileFieldMultiTSWithoutSDA(*this); @@ -6853,6 +6861,11 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TS return new MEDFileIntField1TSWithoutSDA; } +const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception) +{ + return MEDFileIntField1TSWithoutSDA::TYPE_STR; +} + MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception) { return new MEDFileIntFieldMultiTSWithoutSDA(*this); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index efea43ad8..4c48b05b1 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -465,9 +465,10 @@ namespace ParaMEDMEM int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception); void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const = 0; + virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; virtual MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception) = 0; virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0; + virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0; virtual DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) = 0; virtual DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception) = 0; virtual void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception) = 0; @@ -505,7 +506,7 @@ namespace ParaMEDMEM class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA { public: - void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); DataArrayDouble *getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception); @@ -527,6 +528,8 @@ namespace ParaMEDMEM const DataArrayDouble *getOrCreateAndGetArrayDouble() const; protected: MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr; + public: + static const char TYPE_STR[]; }; /*! @@ -537,9 +540,9 @@ namespace ParaMEDMEM public: MEDFileIntField1TSWithoutSDA(); static MEDFileIntField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); - void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception); + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception); @@ -554,6 +557,8 @@ namespace ParaMEDMEM MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); protected: MEDCouplingAutoRefCountObjectPtr< DataArrayInt > _arr; + public: + static const char TYPE_STR[]; }; /*! @@ -720,6 +725,7 @@ namespace ParaMEDMEM public: std::size_t getHeapMemorySize() const; virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception); + virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0; virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0; virtual MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception) = 0; const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); @@ -773,6 +779,7 @@ namespace ParaMEDMEM public: static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep) throw(INTERP_KERNEL::Exception); MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception); + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception); std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); protected: @@ -789,6 +796,7 @@ namespace ParaMEDMEM public: static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep) throw(INTERP_KERNEL::Exception); MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception); + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception); protected: MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName); diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 6e18524a8..cf2f117fd 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1326,6 +1326,11 @@ namespace ParaMEDMEM return MEDFileIntField1TS::New(fileName,fieldName,iteration,order); } + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + PyObject *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception) { DataArrayInt *ret1=0; @@ -1838,6 +1843,11 @@ namespace ParaMEDMEM return MEDFileIntFieldMultiTS::New(fileName,fieldName); } + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + PyObject *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception) { DataArrayInt *ret1=0; diff --git a/src/MEDLoader/Swig/MEDLoaderTypemaps.i b/src/MEDLoader/Swig/MEDLoaderTypemaps.i index bbfad3650..50283b8f8 100644 --- a/src/MEDLoader/Swig/MEDLoaderTypemaps.i +++ b/src/MEDLoader/Swig/MEDLoaderTypemaps.i @@ -23,6 +23,11 @@ static PyObject* convertMEDFileMesh(ParaMEDMEM::MEDFileMesh* mesh, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!mesh) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(mesh)) ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileUMesh,owner); if(dynamic_cast(mesh)) @@ -37,6 +42,11 @@ static PyObject* convertMEDFileMesh(ParaMEDMEM::MEDFileMesh* mesh, int owner) th static PyObject* convertMEDFileParameter1TS(ParaMEDMEM::MEDFileParameter1TS* p1ts, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!p1ts) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(p1ts)) ret=SWIG_NewPointerObj((void*)p1ts,SWIGTYPE_p_ParaMEDMEM__MEDFileParameterDouble1TS,owner); if(dynamic_cast(p1ts)) @@ -49,6 +59,11 @@ static PyObject* convertMEDFileParameter1TS(ParaMEDMEM::MEDFileParameter1TS* p1t static PyObject* convertMEDFileField1TS(ParaMEDMEM::MEDFileAnyTypeField1TS *p, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; + if(!p) + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(p)) ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileField1TS,owner); if(dynamic_cast(p)) @@ -62,7 +77,10 @@ static PyObject* convertMEDFileFieldMultiTS(ParaMEDMEM::MEDFileAnyTypeFieldMulti { PyObject *ret=0; if(!p) - return SWIG_NewPointerObj((void*)0,SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,owner); + { + Py_XINCREF(Py_None); + return Py_None; + } if(dynamic_cast(p)) ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,owner); if(dynamic_cast(p)) diff --git a/src/MEDLoader/Test/SauvLoaderTest.cxx b/src/MEDLoader/Test/SauvLoaderTest.cxx index fdc9146a4..113633c73 100644 --- a/src/MEDLoader/Test/SauvLoaderTest.cxx +++ b/src/MEDLoader/Test/SauvLoaderTest.cxx @@ -219,7 +219,7 @@ void SauvLoaderTest::testMed2Sauv() MEDFileFields* pointeFields = pointeMed->getFields(); for ( int i = 0; i < pointeFields->getNumberOfFields(); ++i ) { - MEDCouplingAutoRefCountObjectPtr ts = dynamic_cast(pointeFields->getFieldAtPos(i)); + MEDCouplingAutoRefCountObjectPtr ts = pointeFields->getFieldAtPos(i); if ( std::string("fieldnodeint") == ts->getName()) { pointeFields->destroyFieldAtPos( i );