From: Gilles DAVID Date: Sat, 26 Oct 2024 09:46:22 +0000 (+0200) Subject: Compatibility Python 3.13+ X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=084151f1a7104b71bee31f8a3c46e374ed070061;p=modules%2Fkernel.git Compatibility Python 3.13+ --- diff --git a/src/DSC/DSC_Python/calcium.i b/src/DSC/DSC_Python/calcium.i index 3d50af19d..5b81f3aa1 100644 --- a/src/DSC/DSC_Python/calcium.i +++ b/src/DSC/DSC_Python/calcium.i @@ -702,28 +702,52 @@ CORBAPTR(PortableServer::POA) catch(Engines::DSC::PortNotDefined& _e) { Py_BLOCK_THREADS PyObject* excc = PyObject_GetAttrString(dsc, "PortNotDefined"); +#if (PY_VERSION_HEX >= 0x03070000) // Python 3.7 or later + PyObject* emptyTuple = Py_BuildValue("()"); + PyObject* exci = PyObject_CallObject(excc, emptyTuple); +#else // Python 3.0 - 3.6 PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL); +#endif PyErr_SetObject(excc, exci); Py_XDECREF(excc); Py_XDECREF(exci); +#if (PY_VERSION_HEX >= 0x03070000) // Python 3.7 or later + Py_DECREF(emptyTuple); +#endif return NULL; } catch(Engines::DSC::PortNotConnected& _e) { Py_BLOCK_THREADS PyObject* excc = PyObject_GetAttrString(dsc, "PortNotConnected"); +#if (PY_VERSION_HEX >= 0x03070000) // Python 3.7 or later + PyObject* emptyTuple = Py_BuildValue("()"); + PyObject* exci = PyObject_CallObject(excc, emptyTuple); +#else // Python 3.0 - 3.6 PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL); +#endif PyErr_SetObject(excc, exci); Py_XDECREF(excc); Py_XDECREF(exci); +#if (PY_VERSION_HEX >= 0x03070000) // Python 3.7 or later + Py_DECREF(emptyTuple); +#endif return NULL; } catch(Engines::DSC::BadPortType& _e) { Py_BLOCK_THREADS PyObject* excc = PyObject_GetAttrString(dsc, "BadPortType"); +#if (PY_VERSION_HEX >= 0x03070000) // Python 3.7 or later + PyObject* emptyTuple = Py_BuildValue("()"); + PyObject* exci = PyObject_CallObject(excc, emptyTuple); +#else // Python 3.0 - 3.6 PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL); +#endif PyErr_SetObject(excc, exci); Py_XDECREF(excc); Py_XDECREF(exci); +#if (PY_VERSION_HEX >= 0x03070000) // Python 3.7 or later + Py_DECREF(emptyTuple); +#endif return NULL; } catch (SALOME_Exception &e) {