From 5ee69ad26ea78f94a37f3f63f8f22fbfc8b19606 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 2 Mar 2015 12:28:01 +0100 Subject: [PATCH] First test OK for DataArrayDouble. --- src/MEDCoupling_Swig/MEDCouplingMemArray.i | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 4aefb7327..d7ec98b1d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -2182,12 +2182,20 @@ namespace ParaMEDMEM static const char MSG[]="DataArrayDouble.__new__ : the args in input is expected to be a tuple of size 2 !"; if(!PyTuple_Check(args)) throw INTERP_KERNEL::Exception(MSG); - PyObject *globals(PyEval_GetGlobals());//borrowed - PyObject *builtins(PyDict_GetItemString(globals,"__builtins__"));//borrowed - PyObject *obj(PyObject_GetAttrString(builtins,"object")); + //PyObject *globals(PyEval_GetGlobals());//borrowed + //PyObject *builtins(PyDict_GetItemString(globals,"__builtins__"));//borrowed + //PyObject *builtinsd(PyModule_GetDict(builtins));//borrowed + PyObject *builtinsd(PyEval_GetBuiltins());//borrowed + PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed + //PyObject *obj(PyObject_GetAttrString(builtins,"object")); PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__")); - Py_DECREF(obj); - PyObject *instance(PyObject_CallObject(selfMeth,PyTuple_GetItem(args,0))); + //Py_DECREF(obj); + ///// + PyObject *tmp0(PyTuple_New(1)); + PyTuple_SetItem(tmp0,0,PyTuple_GetItem(args,0)); Py_DECREF(PyTuple_GetItem(args,0)); + PyObject *instance(PyObject_CallObject(selfMeth,tmp0)); + Py_DECREF(tmp0); + ///// Py_DECREF(selfMeth); PyObject *initMeth(PyObject_GetAttrString(instance,"__init__")); if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1))) -- 2.39.2