diff options
author | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:25:57 +0300 |
---|---|---|
committer | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:25:57 +0300 |
commit | 2342e61cb53824e2dcd6324e3d108500d61ffee2 (patch) | |
tree | 2899ebce2effcb9e3bd5622fbdb371f75feadd59 /sources/shiboken2/libshiboken | |
parent | e31990ada911989dbcef3d4833f77dd054030e2c (diff) | |
parent | b9cf35960e98adf9af7c4ea2cc09bfbdadf4f71f (diff) |
Merge tag 'v5.15.8-lts' into tqtc/lts-5.15-opensourcev5.15.8-lts-lgpl
Qt For Python Release 5.15.8
Change-Id: Ib92716482ef78eead1859f4f0c980b308a6e5846
Diffstat (limited to 'sources/shiboken2/libshiboken')
7 files changed, 41 insertions, 23 deletions
diff --git a/sources/shiboken2/libshiboken/autodecref.h b/sources/shiboken2/libshiboken/autodecref.h index 498b1aec4..6e6d5db95 100644 --- a/sources/shiboken2/libshiboken/autodecref.h +++ b/sources/shiboken2/libshiboken/autodecref.h @@ -101,6 +101,14 @@ public: m_pyObj = other; Py_XDECREF(_py_tmp); } + + PyObject *release() + { + PyObject *result = m_pyObj; + m_pyObj = nullptr; + return result; + } + private: PyObject *m_pyObj; }; diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index cb8042561..66df0fd94 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -754,11 +754,13 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name) #ifndef Py_LIMITED_API return _Py_Mangle(privateobj, name); #else - // For some reason, _Py_Mangle is not in the Limited API. Why? - size_t plen = PyUnicode_GET_LENGTH(privateobj); + // PYSIDE-1436: _Py_Mangle is no longer exposed; implement it always. + // The rest of this function is our own implementation of _Py_Mangle. + // Please compare the original function in compile.c . + size_t plen = PyUnicode_GET_LENGTH(privateobj.object()); /* Strip leading underscores from class name */ size_t ipriv = 0; - while (PyUnicode_READ_CHAR(privateobj, ipriv) == '_') + while (PyUnicode_READ_CHAR(privateobj.object(), ipriv) == '_') ipriv++; if (ipriv == plen) { Py_INCREF(name); diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h index 7a6f57fcd..eb65596cc 100644 --- a/sources/shiboken2/libshiboken/pep384impl.h +++ b/sources/shiboken2/libshiboken/pep384impl.h @@ -40,6 +40,11 @@ #ifndef PEP384IMPL_H #define PEP384IMPL_H +// PYSIDE-1436: Adapt to Python 3.10 +#if PY_VERSION_HEX < 0x030900A4 +# define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0) +#endif + extern "C" { @@ -327,7 +332,7 @@ LIBSHIBOKEN_API PyObject *PyRun_String(const char *, int, PyObject *, PyObject * // But this is no problem as we check it's validity for every version. #define PYTHON_BUFFER_VERSION_COMPATIBLE (PY_VERSION_HEX >= 0x03030000 && \ - PY_VERSION_HEX < 0x0309FFFF) + PY_VERSION_HEX < 0x030AFFFF) #if !PYTHON_BUFFER_VERSION_COMPATIBLE # error Please check the buffer compatibility for this python version! #endif diff --git a/sources/shiboken2/libshiboken/sbkstring.cpp b/sources/shiboken2/libshiboken/sbkstring.cpp index 918aae756..077fb531b 100644 --- a/sources/shiboken2/libshiboken/sbkstring.cpp +++ b/sources/shiboken2/libshiboken/sbkstring.cpp @@ -247,7 +247,7 @@ static void finalizeStaticStrings() { auto &set = staticStrings(); for (PyObject *ob : set) { - Py_REFCNT(ob) = 1; + Py_SET_REFCNT(ob, 1); Py_DECREF(ob); } set.clear(); diff --git a/sources/shiboken2/libshiboken/signature/signature.cpp b/sources/shiboken2/libshiboken/signature/signature.cpp index 3051c50d5..191af3d9b 100644 --- a/sources/shiboken2/libshiboken/signature/signature.cpp +++ b/sources/shiboken2/libshiboken/signature/signature.cpp @@ -471,6 +471,9 @@ static PyObject *adjustFuncName(const char *func_name) // Run `eval` on the type string to get the object. AutoDecRef obtype(PyRun_String(_path, Py_eval_input, ns, ns)); + if (obtype.isNull()) + return String::fromCString(func_name); + if (PyModule_Check(obtype.object())) { // This is a plain function. Return the unmangled name. return String::fromCString(func_name); diff --git a/sources/shiboken2/libshiboken/signature/signature_extend.cpp b/sources/shiboken2/libshiboken/signature/signature_extend.cpp index 1490a6003..c1918c492 100644 --- a/sources/shiboken2/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken2/libshiboken/signature/signature_extend.cpp @@ -157,25 +157,25 @@ static PyObject *handle_doc(PyObject *ob, PyObject *old_descr) init_module_2(); AutoDecRef ob_type_mod(GetClassOrModOf(ob)); const char *name; - if (PyModule_Check(ob_type_mod)) - name = PyModule_GetName(ob_type_mod); + if (PyModule_Check(ob_type_mod.object())) + name = PyModule_GetName(ob_type_mod.object()); else name = reinterpret_cast<PyTypeObject *>(ob_type_mod.object())->tp_name; - if (handle_doc_in_progress || name == nullptr - || strncmp(name, "PySide2.", 8) != 0) - return PyObject_CallMethodObjArgs(old_descr, - PyMagicName::get(), - ob, nullptr); - handle_doc_in_progress++; - PyObject *res = PyObject_CallFunction( - pyside_globals->make_helptext_func, - const_cast<char *>("(O)"), ob); - handle_doc_in_progress--; - if (res == nullptr) { - PyErr_Print(); - Py_FatalError("handle_doc did not receive a result"); + PyObject *res{}; + + if (handle_doc_in_progress || name == nullptr || strncmp(name, "PySide2.", 8) != 0) { + res = PyObject_CallMethodObjArgs(old_descr, PyMagicName::get(), ob, nullptr); + } else { + handle_doc_in_progress++; + res = PyObject_CallFunction(pyside_globals->make_helptext_func, "(O)", ob); + handle_doc_in_progress--; } - return res; + + if (res) + return res; + + PyErr_Clear(); + Py_RETURN_NONE; } static PyObject *pyside_cf_get___doc__(PyObject *cf) diff --git a/sources/shiboken2/libshiboken/signature/signature_helper.cpp b/sources/shiboken2/libshiboken/signature/signature_helper.cpp index 2b360c786..0246ec61d 100644 --- a/sources/shiboken2/libshiboken/signature/signature_helper.cpp +++ b/sources/shiboken2/libshiboken/signature/signature_helper.cpp @@ -236,7 +236,7 @@ static PyObject *_build_new_entry(PyObject *new_name, PyObject *value) PyObject *new_value = PyDict_Copy(value); PyObject *multi = PyDict_GetItem(value, PyName::multi()); if (multi != nullptr && Py_TYPE(multi) == &PyList_Type) { - ssize_t len = PyList_Size(multi); + Py_ssize_t len = PyList_Size(multi); AutoDecRef list(PyList_New(len)); if (list.isNull()) return nullptr; @@ -314,7 +314,7 @@ PyObject *_address_to_stringlist(PyObject *numkey) * When needed in `PySide_BuildSignatureProps`, the strings are * finally materialized. */ - ssize_t address = PyNumber_AsSsize_t(numkey, PyExc_ValueError); + Py_ssize_t address = PyNumber_AsSsize_t(numkey, PyExc_ValueError); if (address == -1 && PyErr_Occurred()) return nullptr; char **sig_strings = reinterpret_cast<char **>(address); |