From 084151f1a7104b71bee31f8a3c46e374ed070061 Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Sat, 26 Oct 2024 11:46:22 +0200 Subject: [PATCH] Compatibility Python 3.13+ --- src/DSC/DSC_Python/calcium.i | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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) { -- 2.39.2