]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Compatibility Python 3.13+
authorGilles DAVID <gilles-g.david@edf.fr>
Sat, 26 Oct 2024 09:46:22 +0000 (11:46 +0200)
committerGilles DAVID <gilles-g.david@edf.fr>
Sat, 26 Oct 2024 11:07:20 +0000 (13:07 +0200)
src/DSC/DSC_Python/calcium.i

index 3d50af19dcfe42e8f4cec2b325d1eb0752359fde..5b81f3aa179f10247fba205ee0315ce10e5bf1b2 100644 (file)
@@ -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) {