#include "TypeCode.hxx"
#include "Cstr2d.hxx"
#include "SALOME_GenericObj.hh"
+#include "PythonNode.hxx"
#include <iostream>
#include <iomanip>
static inline double convert(const TypeCode *t,PyObject* o,void*)
{
double x;
- if (PyFloat_Check(o))
- x=PyFloat_AS_DOUBLE(o);
- else if(PyLong_Check(o))
- x=PyLong_AsLong(o);
- else
+ x=PyFloat_AsDouble(o);
+ if( PyErr_Occurred() )
{
+ PyErr_Restore(nullptr,nullptr,nullptr);
stringstream msg;
msg << "Not a python double. ";
#ifdef _DEVDEBUG_
static inline long convert(const TypeCode *t,PyObject* o,void*)
{
long l;
- if(PyLong_Check(o))
- l=PyLong_AsLong(o);
- else
+ l=PyLong_AsLong(o);
+ if( PyErr_Occurred() )
{
+ PyErr_Restore(nullptr,nullptr,nullptr);
stringstream msg;
msg << "Not a python integer. ";
#ifdef _DEVDEBUG_
}
if(strncmp(t->id(),"python",6)==0)
{
+ bool somthingToDo = YACS::ENGINE::PythonEntry::GetDestroyStatus(o);
+ if( somthingToDo )
+ YACS::ENGINE::PythonEntry::DoNotTouchFileIfProxy(o);
// It's a native Python object pickle it
PyObject* mod=PyImport_ImportModule("pickle");
PyObject *pickled=PyObject_CallMethod(mod,(char *)"dumps",(char *)"Oi",o,protocol);
+ if( somthingToDo )
+ YACS::ENGINE::PythonEntry::UnlinkOnDestructorIfProxy(o);
DEBTRACE(PyObject_Repr(pickled) );
Py_DECREF(mod);
if(pickled==NULL)