diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-01-10 18:50:57 +0900 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2023-01-13 03:28:05 +0100 |
commit | d85bd77116b2cf7e7565a0905b53ff0fa2a5b50e (patch) | |
tree | 4a50744dcf8fbfeee8098646bb75332b7e1bfaec /dcoppython/shell/pcop.cpp | |
parent | 3b188e184dc679e04975fbc2b572287fdcff0cca (diff) | |
download | tdebindings-d85bd77116b2cf7e7565a0905b53ff0fa2a5b50e.tar.gz tdebindings-d85bd77116b2cf7e7565a0905b53ff0fa2a5b50e.zip |
Drop support for python2.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'dcoppython/shell/pcop.cpp')
-rw-r--r-- | dcoppython/shell/pcop.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/dcoppython/shell/pcop.cpp b/dcoppython/shell/pcop.cpp index 19557a14..01b45c7f 100644 --- a/dcoppython/shell/pcop.cpp +++ b/dcoppython/shell/pcop.cpp @@ -188,7 +188,7 @@ namespace PythonDCOP { it.current(); ++it, ++c) { PyObject *tuple = PyTuple_New(2); PyList_SetItem(result, c, tuple); - PyTuple_SetItem(tuple, 0, PyString_FromString(it.currentKey() ) ); + PyTuple_SetItem(tuple, 0, PyBytes_FromString(it.currentKey() ) ); PyTuple_SetItem(tuple, 1, it.current()->pythonMethod() ); } return result; @@ -593,7 +593,7 @@ namespace PythonDCOP { QCStringList::ConstIterator end = apps.end(); unsigned int i = 0; for (; it != end; ++it, i++ ) - PyList_SetItem( l, i, PyString_FromString( (*it).data() ) ); + PyList_SetItem( l, i, PyBytes_FromString( (*it).data() ) ); return l; } @@ -621,7 +621,7 @@ namespace PythonDCOP { int add_pid = 1; if (PyArg_ParseTuple(args, (char*)"s|i", &appid, &add_pid)) { TQCString actual_appid = Client::instance()->dcop()->registerAs(TQCString(appid), add_pid!=0); - return PyString_FromString(actual_appid.data()); + return PyBytes_FromString(actual_appid.data()); } return NULL; } @@ -632,7 +632,7 @@ namespace PythonDCOP { if (PyArg_ParseTuple(args, (char*)"O|s", &py_dcop_object, &objid)) { Py_INCREF(py_dcop_object); PCOPObject *obj = objid ? new PCOPObject(py_dcop_object, objid) : new PCOPObject(py_dcop_object); - return PyCObject_FromVoidPtr( (void*)obj, delete_dcop_object ); + return PyCapsule_New( (void*)obj, NULL, (PyCapsule_Destructor)delete_dcop_object ); } return NULL; } @@ -646,7 +646,7 @@ namespace PythonDCOP { PyObject *c_obj; PyObject *method_list; if (PyArg_ParseTuple(args, (char*)"OO", &c_obj, &method_list) && - PyCObject_Check(c_obj) && + PyCapsule_CheckExact(c_obj) && PyList_Check(method_list)) { // extract each tuple from the list, aborting if any is invalid @@ -662,7 +662,7 @@ namespace PythonDCOP { meth_list.insert(method_signature, py_method); } - PCOPObject *obj = (PCOPObject*)PyCObject_AsVoidPtr(c_obj); + PCOPObject *obj = (PCOPObject*)PyCapsule_GetPointer(c_obj, NULL); if (obj) { if (!obj->setMethodList(meth_list)) return NULL; } @@ -675,8 +675,8 @@ namespace PythonDCOP { PyObject *get_method_list(PyObject */*self*/, PyObject *args) { PyObject *c_obj; if (PyArg_ParseTuple(args, (char*)"O", &c_obj)) { - if (PyCObject_Check(c_obj)) { - PCOPObject *obj = (PCOPObject*)PyCObject_AsVoidPtr(c_obj); + if (PyCapsule_CheckExact(c_obj)) { + PCOPObject *obj = (PCOPObject*)PyCapsule_GetPointer(c_obj, NULL); return obj->methodList(); } } @@ -736,7 +736,7 @@ namespace PythonDCOP { for(QCStringList::ConstIterator it = qt_list.begin(); it!=qt_list.end(); ++it,c++) - PyList_SetItem(l, c, PyString_FromString( (*it).data() ) ); + PyList_SetItem(l, c, PyBytes_FromString( (*it).data() ) ); return l; } @@ -757,14 +757,20 @@ PyMethodDef PCOPMethods[] = { { NULL, NULL, 0, NULL } /* Sentinel */ }; +static struct PyModuleDef pcopmodule = { + PyModuleDef_HEAD_INIT, + "pcop", + NULL, + -1, + PCOPMethods +}; + extern "C" { - - void initpcop() - { - (void) Py_InitModule( (char*)"pcop", PCOPMethods ); - } - + PyMODINIT_FUNC PyInit_pcop(void) + { + return PyModule_Create(&pcopmodule); + } } |