From 047f817bc2bd9f7463a4690e68e80a07f98f9681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo=20F=C3=A4lt?= Date: Wed, 29 Sep 2021 15:12:02 +0300 Subject: Update virtualenv version Old version was giving "ModuleNotFoundError: No module named 'virtualenv.activation.nushell' error. Change-Id: I2ff72b570fd8aeaf542b786934e545c8a0283fae Reviewed-by: Friedemann Kleint (cherry picked from commit aa1461724164eb0d9162b0dc4f3418f7e0b26300) --- coin_build_instructions.py | 2 +- coin_test_instructions.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coin_build_instructions.py b/coin_build_instructions.py index cf5dca62e..6a4d5dfd7 100644 --- a/coin_build_instructions.py +++ b/coin_build_instructions.py @@ -112,7 +112,7 @@ def call_setup(python_ver, phase): if phase in ["BUILD"]: rmtree(_env, True) # Pinning the virtualenv before creating one - run_instruction(["pip", "install", "--user", "virtualenv==20.0.25"], "Failed to pin virtualenv") + run_instruction(["pip", "install", "--user", "virtualenv==20.7.2"], "Failed to pin virtualenv") # installing to user base might not be in PATH by default. env_path = os.path.join(site.USER_BASE, "bin") v_env = os.path.join(env_path, "virtualenv") diff --git a/coin_test_instructions.py b/coin_test_instructions.py index 3b8f7e39c..4ba5ac9ff 100644 --- a/coin_test_instructions.py +++ b/coin_test_instructions.py @@ -67,7 +67,7 @@ def call_testrunner(python_ver, buildnro): _pExe, _env, env_pip, env_python = get_qtci_virtualEnv(python_ver, CI_HOST_OS, CI_HOST_ARCH, CI_TARGET_ARCH) rmtree(_env, True) # Pinning the virtualenv before creating one - run_instruction(["pip", "install", "--user", "virtualenv==20.0.25"], "Failed to pin virtualenv") + run_instruction(["pip", "install", "--user", "virtualenv==20.7.2"], "Failed to pin virtualenv") # installing to user base might not be in PATH by default. env_path = os.path.join(site.USER_BASE, "bin") v_env = os.path.join(env_path, "virtualenv") -- cgit v1.2.3 From 5f7e8df26fd85647288a6dfa975ab7b0f7110471 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Oct 2021 12:58:50 +0200 Subject: shiboken6: Fix debug operator of AbstractMetaEnumValue It should print the name always. Change-Id: Ie44382a2a8f7901a96f2901a4bb21b2ed22b7197 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit e8555cc435c0da9d72601447a5ed69a2a0180d47) --- sources/shiboken2/ApiExtractor/abstractmetalang.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index 06d5af14c..7e220bbdc 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -1855,10 +1855,7 @@ QDebug operator<<(QDebug d, const AbstractMetaField *af) static void formatMetaEnumValue(QDebug &d, const AbstractMetaEnumValue *v) { - const QString &name = v->stringValue(); - if (!name.isEmpty()) - d << name << '='; - d << v->value(); + d << v->name() << '=' << v->value(); } QDebug operator<<(QDebug d, const AbstractMetaEnumValue *v) -- cgit v1.2.3 From 5f1459ac96ab97f85d1391b7d3ec424c782e5b52 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 1 Nov 2021 09:02:43 +0100 Subject: shiboken6: Fix a leak in keyword arguments handling Free the kwds_dup dictionary. Add a release() method to AutoDecRef to be able to swap the kwds_dup dictionary into errInfo. Fixes: PYSIDE-1697 Change-Id: I82de6d1f1201a079b4e7a72fe20ea932695af827 Reviewed-by: Christian Tismer (cherry picked from commit 3d9fa77b9fd556fdd87125aa33ce0a3bf8dda3f9) --- sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 4 ++-- sources/shiboken2/libshiboken/autodecref.h | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index eb9199292..5a80e4893 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -3250,7 +3250,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe { Indentation indent(INDENT); s << INDENT << "PyObject *value{};\n"; - s << INDENT << "PyObject *kwds_dup = PyDict_Copy(kwds);\n"; + s << INDENT << "Shiboken::AutoDecRef kwds_dup(PyDict_Copy(kwds));\n"; for (const AbstractMetaArgument *arg : args) { const int pyArgIndex = arg->argumentIndex() - OverloadData::numberOfRemovedArguments(func, arg->argumentIndex()); @@ -3295,7 +3295,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe s << INDENT << "if (PyDict_Size(kwds_dup) > 0) {\n"; { Indentation indent(INDENT); - s << INDENT << "errInfo = kwds_dup;\n"; + s << INDENT << "errInfo = kwds_dup.release();\n"; if (!(func->isConstructor() && func->ownerClass()->isQObject())) s << INDENT << "goto " << cpythonFunctionName(func) << "_TypeError;\n"; else diff --git a/sources/shiboken2/libshiboken/autodecref.h b/sources/shiboken2/libshiboken/autodecref.h index bcade8ae6..eb02594bb 100644 --- a/sources/shiboken2/libshiboken/autodecref.h +++ b/sources/shiboken2/libshiboken/autodecref.h @@ -83,6 +83,14 @@ public: m_pyObj = other; Py_XDECREF(_py_tmp); } + + PyObject *release() + { + PyObject *result = m_pyObj; + m_pyObj = nullptr; + return result; + } + private: PyObject *m_pyObj; }; -- cgit v1.2.3 From 380ac3cae4f0224d0c0e92b5e78a83ac3d7dc688 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Nov 2021 14:32:13 +0100 Subject: Fix build with MSVC 19.29.30136 The POSIX type ssize_t was removed. Replace py Py_ssize_t. Fixes: PYSIDE-1703 Change-Id: I39d7b1df9cff2e9d5ad1290adb5a26745d8e5d24 Reviewed-by: Alexandru Croitor (cherry picked from commit f6cf8edabc76ac18d56a3a5b76e11e4f98df3f47) --- sources/shiboken2/libshiboken/signature/signature_helper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/shiboken2/libshiboken/signature/signature_helper.cpp b/sources/shiboken2/libshiboken/signature/signature_helper.cpp index 4d6dbe08e..e7f375069 100644 --- a/sources/shiboken2/libshiboken/signature/signature_helper.cpp +++ b/sources/shiboken2/libshiboken/signature/signature_helper.cpp @@ -218,7 +218,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; @@ -296,7 +296,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(address); -- cgit v1.2.3 From 6bff39f3f291feedd104d7ad385b3209fa15f3c6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Nov 2021 10:32:29 +0100 Subject: shiboken6: Clean up messages about cyclic dependencies of overloaded functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move message helper msgCyclicDependency() from overloaddata.cpp to message.cpp to prevent a clash between the static helper and the one declared in messages.h. This was an oversight causing problems in 5.15: tqtc-pyside-setup/sources/shiboken2/generator/shiboken2/overloaddata.cpp: In function ‘QString msgCyclicDependency(const QString&, const QString&, const MetaFunctionList&)’: tqtc-pyside-setup/sources/shiboken2/generator/shiboken2/overloaddata.cpp:151:16: error: ‘QString msgCyclicDependency(const QString&, const QString&, const MetaFunctionList&)’ was declared ‘extern’ and later ‘static’ [-fpermissive] Change-Id: I56375c5bbc483859f83658cfeb4df1e6067421a0 Reviewed-by: Christian Tismer (cherry picked from commit 8430d4e02940c2d3fd9493044e05f9e113c07001) --- .../shiboken2/generator/shiboken2/overloaddata.cpp | 23 +--------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp index cae8569fb..93d4f3d99 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp +++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp @@ -23,6 +23,7 @@ #include #include #include "overloaddata.h" +#include "messages.h" #include "ctypenames.h" #include "indentor.h" #include "shibokengenerator.h" @@ -146,28 +147,6 @@ static QString getImplicitConversionTypeName(const AbstractMetaType *containerTy + types.join(QLatin1String(", ")) + QLatin1String(" >"); } -// overloaddata.cpp -static QString msgCyclicDependency(const QString &funcName, const QString &graphName, - const OverloadData::MetaFunctionList &involvedConversions) -{ - QString result; - QTextStream str(&result); - str << "Cyclic dependency found on overloaddata for \"" << funcName - << "\" method! The graph boy saved the graph at \"" << QDir::toNativeSeparators(graphName) - << "\"."; - if (const int count = involvedConversions.size()) { - str << " Implicit conversions (" << count << "): "; - for (int i = 0; i < count; ++i) { - if (i) - str << ", \""; - str << involvedConversions.at(i)->signature() << '"'; - if (const AbstractMetaClass *c = involvedConversions.at(i)->implementingClass()) - str << '(' << c->name() << ')'; - } - } - return result; -} - static inline int overloadNumber(const OverloadData *o) { return o->referenceFunction()->overloadNumber(); -- cgit v1.2.3 From 567ef11d591d54f0de7e682213d4fd9efdf1afe0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Oct 2021 09:56:41 +0200 Subject: shiboken6: Do not crash when class cannot be found in the overload sorter Print an error message instead. As a drive-by, add a helper to create a class-qualified signature for error reporting purposes to AbstractMetaFunction. Task-number: PYSIDE-1684 Change-Id: I8417f405b4ce1b64060aad0696e5d328869cb83e Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 1e7f97e082d5430ff8323bc58c480d00a4f64852) --- sources/shiboken2/ApiExtractor/messages.cpp | 13 +++++++++++++ sources/shiboken2/ApiExtractor/messages.h | 3 +++ sources/shiboken2/generator/shiboken2/overloaddata.cpp | 5 ++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sources/shiboken2/ApiExtractor/messages.cpp b/sources/shiboken2/ApiExtractor/messages.cpp index 48d3f6abf..16a19adca 100644 --- a/sources/shiboken2/ApiExtractor/messages.cpp +++ b/sources/shiboken2/ApiExtractor/messages.cpp @@ -671,3 +671,16 @@ QString msgFallbackWarning(const QXmlStreamReader &reader, const QString &contex message += QLatin1String(" [") + identifier + QLatin1Char(']'); return msgTagWarning(reader, context, tag, message); } + +QString msgArgumentClassNotFound(const AbstractMetaFunction *func, + const TypeEntry *t) +{ + QString result; + QTextStream str(&result); + str << "Internal Error: Class \"" << t->qualifiedCppName() + << "\" for \""; + if (auto *ic = func->implementingClass()) + str << ic->qualifiedCppName() << "::"; + str << func->signature() << "\" not found!"; + return result; +} diff --git a/sources/shiboken2/ApiExtractor/messages.h b/sources/shiboken2/ApiExtractor/messages.h index 267c45a84..c4aeb3c4c 100644 --- a/sources/shiboken2/ApiExtractor/messages.h +++ b/sources/shiboken2/ApiExtractor/messages.h @@ -196,4 +196,7 @@ QString msgFallbackWarning(const QXmlStreamReader &reader, const QString &contex const QString &tag, const QString &location, const QString &identifier, const QString &fallback); +QString msgArgumentClassNotFound(const AbstractMetaFunction *func, + const TypeEntry *t); + #endif // MESSAGES_H diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp index 93d4f3d99..808d73de3 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp +++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp @@ -302,7 +302,10 @@ void OverloadData::sortNextOverloads() // Process inheritance relationships if (targetType->isValue() || targetType->isObject()) { - const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_generator->classes(), targetType->typeEntry()); + auto *te = targetType->typeEntry(); + const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_generator->classes(), te); + if (!metaClass) + qFatal("%s", qPrintable(msgArgumentClassNotFound(m_overloads.constFirst(), te))); const AbstractMetaClassList &ancestors = m_generator->getAllAncestors(metaClass); for (const AbstractMetaClass *ancestor : ancestors) { QString ancestorTypeName = ancestor->typeEntry()->name(); -- cgit v1.2.3 From 893f07e845f32c375c65675591df1c0cdaf4cb07 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Nov 2021 13:30:49 +0100 Subject: Handle crash when passing arguments of wrong type in embedded application When passing arguments of wrong type in the scriptableapplication example, PyRun_String() fails and a crash occurs (NameError: name 'AppLib' is not defined). Catch this and return nullptr to get at an error message. Change-Id: Ie22cf81ebb0c390bb31684eadf19b682e4487361 Reviewed-by: Christian Tismer (cherry picked from commit 7d6ea931fdc0d919ac9fa5ddadeb931c2578151f) --- sources/shiboken2/libshiboken/signature/signature.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/shiboken2/libshiboken/signature/signature.cpp b/sources/shiboken2/libshiboken/signature/signature.cpp index 6880ea1f2..33157f5cb 100644 --- a/sources/shiboken2/libshiboken/signature/signature.cpp +++ b/sources/shiboken2/libshiboken/signature/signature.cpp @@ -453,6 +453,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 nullptr; + if (PyModule_Check(obtype.object())) { // This is a plain function. Return the unmangled name. return String::fromCString(func_name); -- cgit v1.2.3 From 73febcf2cce14d3fa90db82b61f868960722fd02 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 5 Nov 2021 11:41:41 +0100 Subject: Allow threads in QtGui.QTextDocument.print_ Reaction on a question on IRC (Vincent Michel @vxgmichel Nov 03 14:30) Change-Id: I979dc2ccb110835daec2904e3c62715deb9c7f08 Task-number: PYSIDE-803 Reviewed-by: Friedemann Kleint (cherry picked from commit 3d903c91f6e00e8cff75e7cc8a0619008dd6c59f) --- sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml index e66ee48ce..617d64355 100644 --- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml +++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml @@ -1824,7 +1824,7 @@ - + -- cgit v1.2.3 From e137bd71d7e876b43a7d7c25d36677492df00a56 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 22 Nov 2021 08:29:32 +0100 Subject: PySide2: Add QSGRendererInterface Task-number: PYSIDE-1716 Change-Id: I72564490469f5b2801ee5a11dd99c7cf08da1b81 Reviewed-by: Christian Tismer --- sources/pyside2/PySide2/QtQuick/CMakeLists.txt | 1 + sources/pyside2/PySide2/QtQuick/typesystem_quick.xml | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/sources/pyside2/PySide2/QtQuick/CMakeLists.txt b/sources/pyside2/PySide2/QtQuick/CMakeLists.txt index 0f453c90e..a500f3bcd 100644 --- a/sources/pyside2/PySide2/QtQuick/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtQuick/CMakeLists.txt @@ -40,6 +40,7 @@ ${QtQuick_GEN_DIR}/qsgopacitynode_wrapper.cpp #${QtQuick_GEN_DIR}/qsgopaquetexturematerial_wrapper.cpp #${QtQuick_GEN_DIR}/qsgsimplematerial_wrapper.cpp #${QtQuick_GEN_DIR}/qsgsimplematerialshader_wrapper.cpp +${QtQuick_GEN_DIR}/qsgrendererinterface_wrapper.cpp ${QtQuick_GEN_DIR}/qsgsimplerectnode_wrapper.cpp ${QtQuick_GEN_DIR}/qsgsimpletexturenode_wrapper.cpp ${QtQuick_GEN_DIR}/qsgtexture_wrapper.cpp diff --git a/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml index 223eff773..4f6d9086c 100644 --- a/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml +++ b/sources/pyside2/PySide2/QtQuick/typesystem_quick.xml @@ -150,6 +150,13 @@ + + + + + + + -- cgit v1.2.3 From 6d3d01d4f0ada188cfa9238a244d8bdd0186fbed Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 19 Nov 2021 10:35:27 +0100 Subject: scriptable: make it work by default on macOS, too Some platforms like Homebrew's macOS name the Python interpreter "python3", while others use "python" as the default name. In any case, it is correct to use the Python 3 version as default, because Python 2 is deprecated. The default now tries "python3" first and falls back to "python". Task-number: PYSIDE-1710 Change-Id: I8850b2c157d219e7785177f41425dca1c2144f99 Reviewed-by: Friedemann Kleint (cherry picked from commit a77c08a6512b079175d08ae1732b9f65c79b687f) Reviewed-by: Qt Cherry-pick Bot --- examples/scriptableapplication/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/scriptableapplication/CMakeLists.txt b/examples/scriptableapplication/CMakeLists.txt index 999206425..5277d17d1 100644 --- a/examples/scriptableapplication/CMakeLists.txt +++ b/examples/scriptableapplication/CMakeLists.txt @@ -16,7 +16,7 @@ find_package(Qt5 5.12 REQUIRED COMPONENTS Core Gui Widgets) # Use provided python interpreter if given. if(NOT python_interpreter) - find_program(python_interpreter "python") + find_program(python_interpreter NAMES python3 python) endif() message(STATUS "Using python interpreter: ${python_interpreter}") -- cgit v1.2.3 From 9dcc454ee166806a5a20516021f82f619bc39b99 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Nov 2021 10:28:39 +0100 Subject: PySide6: Fix crash when connecting slot after disconnecting non-existent connection to same slot Add a null-check. Fixes: PYSIDE-1715 Change-Id: I0fc8c1b051b04eacd6bd75542ceaf9f23a825cab Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 360ef4e884db56e3cd228593bbc562727fbd41cd) Reviewed-by: Christian Tismer --- sources/pyside2/libpyside/globalreceiverv2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sources/pyside2/libpyside/globalreceiverv2.cpp b/sources/pyside2/libpyside/globalreceiverv2.cpp index d3670246e..909c15cc3 100644 --- a/sources/pyside2/libpyside/globalreceiverv2.cpp +++ b/sources/pyside2/libpyside/globalreceiverv2.cpp @@ -273,8 +273,10 @@ void GlobalReceiverV2::notify() #endif Py_BEGIN_ALLOW_THREADS for (const QObject *o : objSet) { - QMetaObject::disconnect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID); - QMetaObject::connect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID); + if (o) { + QMetaObject::disconnect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID); + QMetaObject::connect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID); + } } Py_END_ALLOW_THREADS } -- cgit v1.2.3 From 9fddacfdf636e7f5eab037beef09a8974b9d8d55 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Tue, 7 Dec 2021 15:55:14 +0100 Subject: Signature: fix the __doc__ attribute of classes The signature module had been changed to no longer default the __doc__ attribute of classes to the __init__ signature. This has the side effect of crashing "help(QtCore)". Fixed by correct defaults in C++ (AttributeError) and by setting a "None" default in the Python handler. The make_helptest function defaults again correctly to the signature: >>> errorhandler.make_helptext(QtWidgets.QApplication) 'QApplication(self) -> None\nQApplication(self, arg__1: Sequence[str]) -> None' Change-Id: I140f2b940f98eb126541b18b0feb312c7c4e9728 Fixes: PYSIDE-1727 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 8901719fd74ce8d8909608365e68f7354adaa254) Reviewed-by: Friedemann Kleint --- sources/shiboken2/libshiboken/signature/signature_extend.cpp | 6 ++---- .../files.dir/shibokensupport/signature/errorhandler.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sources/shiboken2/libshiboken/signature/signature_extend.cpp b/sources/shiboken2/libshiboken/signature/signature_extend.cpp index 49ccca0bd..3d4f364f1 100644 --- a/sources/shiboken2/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken2/libshiboken/signature/signature_extend.cpp @@ -153,10 +153,8 @@ static PyObject *handle_doc(PyObject *ob, PyObject *old_descr) pyside_globals->make_helptext_func, const_cast("(O)"), ob); handle_doc_in_progress--; - if (res == nullptr) { - PyErr_Print(); - Py_FatalError("handle_doc did not receive a result"); - } + if (res == nullptr) + PyErr_Format(PyExc_AttributeError, "%R object has no `__doc__` attribute", ob); return res; } diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py index 375b279f1..67ab0d045 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py @@ -136,7 +136,7 @@ def check_string_type(s): return isinstance(s, (str, unicode)) def make_helptext(func): - existing_doc = func.__doc__ + existing_doc = func.__doc__ if hasattr(func, "__doc__") else None sigs = get_signature(func) if not sigs: return existing_doc -- cgit v1.2.3 From 3c1d920da1b3c49a79884799223bb90c2f05a8d5 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Wed, 8 Dec 2021 17:29:27 +0100 Subject: PySide6: Fix a bug in Slot.__call__ While trying to improve MyPy compatibility, a test of Slot()() revealed a missing argument check. The function was also modernized a bit. Task-number: PYSIDE-1675 Change-Id: I0d06931a1dd92b9e55b5bd6e50569c77f6223a4e Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit bd1ad4d23d18132446a936841dc82e444e8e240d) --- sources/pyside2/libpyside/pysideslot.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sources/pyside2/libpyside/pysideslot.cpp b/sources/pyside2/libpyside/pysideslot.cpp index 7ba4e8687..e54cb4175 100644 --- a/sources/pyside2/libpyside/pysideslot.cpp +++ b/sources/pyside2/libpyside/pysideslot.cpp @@ -116,11 +116,13 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw) PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */) { static PyObject *pySlotName = nullptr; - PyObject *callback; - callback = PyTuple_GetItem(args, 0); + PyObject *callback = nullptr; + + if (!PyArg_UnpackTuple(args, "Slot.__call__", 1, 1, &callback)) + return nullptr; Py_INCREF(callback); - if (Py_TYPE(callback)->tp_call != nullptr) { + if (PyCallable_Check(callback)) { PySideSlot *data = reinterpret_cast(self); if (!data->slotData) @@ -129,7 +131,7 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */) if (data->slotData->name.isEmpty()) { // PYSIDE-198: Use PyObject_GetAttr instead of PepFunction_GetName to support Nuitka. AutoDecRef funcName(PyObject_GetAttr(callback, PyMagicName::name())); - data->slotData->name = String::toCString(funcName); + data->slotData->name = funcName.isNull() ? "" : String::toCString(funcName); } const QByteArray returnType = QMetaObject::normalizedType(data->slotData->resultType); const QByteArray signature = @@ -139,7 +141,7 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */) pySlotName = String::fromCString(PYSIDE_SLOT_LIST_ATTR); PyObject *pySignature = String::fromCString(signature); - PyObject *signatureList = 0; + PyObject *signatureList = nullptr; if (PyObject_HasAttr(callback, pySlotName)) { signatureList = PyObject_GetAttr(callback, pySlotName); } else { @@ -154,7 +156,6 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */) //clear data delete data->slotData; data->slotData = nullptr; - return callback; } return callback; } -- cgit v1.2.3 From 4b29cc46f5df9194b85bce5e85fd002604e8fcfe Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 9 Dec 2021 16:42:08 +0100 Subject: Signature: fix the __doc__ attribute of classes, amended This additional change reverts the generation of AttributeError and produces None, instead. Change-Id: I9c9472cdd796b6686d5e7fb46a986ac4366098f2 Fixes: PYSIDE-1727 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 713fed0392f0524ca2eb2779b42c906601c76900) Reviewed-by: Friedemann Kleint --- .../libshiboken/signature/signature_extend.cpp | 32 ++++++++++++---------- .../shibokensupport/signature/errorhandler.py | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sources/shiboken2/libshiboken/signature/signature_extend.cpp b/sources/shiboken2/libshiboken/signature/signature_extend.cpp index 3d4f364f1..b21eb5b60 100644 --- a/sources/shiboken2/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken2/libshiboken/signature/signature_extend.cpp @@ -139,23 +139,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(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("(O)"), ob); - handle_doc_in_progress--; - if (res == nullptr) - PyErr_Format(PyExc_AttributeError, "%R object has no `__doc__` attribute", ob); - return res; + PyObject *res{}; + + if (handle_doc_in_progress || name == nullptr || strncmp(name, "PySide6.", 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--; + } + + if (res) + return res; + + PyErr_Clear(); + Py_RETURN_NONE; } static PyObject *pyside_cf_get___doc__(PyObject *cf) diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py index 67ab0d045..375b279f1 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py @@ -136,7 +136,7 @@ def check_string_type(s): return isinstance(s, (str, unicode)) def make_helptext(func): - existing_doc = func.__doc__ if hasattr(func, "__doc__") else None + existing_doc = func.__doc__ sigs = get_signature(func) if not sigs: return existing_doc -- cgit v1.2.3 From a0ef585ef721710e04ed844cf9fcf574725a2a38 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 18 Nov 2021 11:43:27 +0100 Subject: signature: improve error handling for embedded applications Entering something like """ mainWindow.setPointer(None) """ crashes in an old version of scriptableapplication, which shows an omission in the signature interface. The error shows up whenever a builtin module cannot be imported. The error does not show up in PySide 6, because the module is declared as a builtin via `PyImport_AppendInittab`. * add registration of AppLib as a builtin (5.15) * insert builtin modules per default into the mapping module * simple recovery if a module cannot be found in sys.modules [ChangeLog][shiboken6] Error handling was improved for embedded applications and builtin modules are trusted as valid modules. Change-Id: I722212a52a5e3aae924f0b965578485ecaf185a9 Fixes: PYSIDE-1710 Reviewed-by: Friedemann Kleint (cherry picked from commit 2149a45fddeedea317dccbfe5e5b14e13888e5c9) Reviewed-by: Cristian Maureira-Fredes --- examples/scriptableapplication/mainwindow.cpp | 1 + examples/scriptableapplication/pythonutils.cpp | 8 ++++++++ sources/shiboken2/libshiboken/signature/signature.cpp | 2 +- .../files.dir/shibokensupport/signature/errorhandler.py | 5 ++--- .../files.dir/shibokensupport/signature/mapping.py | 9 ++++++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/scriptableapplication/mainwindow.cpp b/examples/scriptableapplication/mainwindow.cpp index 53aea3c71..4e4135fc6 100644 --- a/examples/scriptableapplication/mainwindow.cpp +++ b/examples/scriptableapplication/mainwindow.cpp @@ -67,6 +67,7 @@ #include static const char defaultScript[] = R"( +import AppLib print("Hello, world") mainWindow.testFunction1() )"; diff --git a/examples/scriptableapplication/pythonutils.cpp b/examples/scriptableapplication/pythonutils.cpp index c5e18f256..920d3e22e 100644 --- a/examples/scriptableapplication/pythonutils.cpp +++ b/examples/scriptableapplication/pythonutils.cpp @@ -68,8 +68,11 @@ extern "C" PyObject *PyInit_AppLib(); #else extern "C" void initAppLib(); +# define PyInit_AppLib initAppLib #endif +static const char moduleName[] = "AppLib"; + // This variable stores all Python types exported by this module. extern PyTypeObject **SbkAppLibTypes; @@ -113,6 +116,11 @@ State init() if (qEnvironmentVariableIsSet(virtualEnvVar)) initVirtualEnvironment(); + if (PyImport_AppendInittab(moduleName, PyInit_AppLib) == -1) { + qWarning("Failed to add the module '%s' to the table of built-in modules.", moduleName); + return state; + } + Py_Initialize(); qAddPostRoutine(cleanup); state = PythonInitialized; diff --git a/sources/shiboken2/libshiboken/signature/signature.cpp b/sources/shiboken2/libshiboken/signature/signature.cpp index 33157f5cb..e17a8e08f 100644 --- a/sources/shiboken2/libshiboken/signature/signature.cpp +++ b/sources/shiboken2/libshiboken/signature/signature.cpp @@ -454,7 +454,7 @@ 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 nullptr; + return String::fromCString(func_name); if (PyModule_Check(obtype.object())) { // This is a plain function. Return the unmangled name. diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py index 375b279f1..41f4403fd 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py @@ -78,12 +78,11 @@ def matched_type(args, sigs): def seterror_argument(args, func_name, info): - func = None try: func = eval(func_name, namespace) except Exception as e: - msg = "Internal error evaluating {func_name}: {e}".format(**locals()) - return TypeError, msg + msg = "Error evaluating `{func_name}`: {e}".format(**locals()) + return type(e), msg if info and type(info) is str: err = TypeError if info == "<": diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index 43f571c08..8dce12a3a 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -39,6 +39,12 @@ from shibokensupport.signature import typing from shibokensupport.signature.typing import TypeVar, Generic from shibokensupport.signature.lib.tool import with_metaclass +if sys.version_info[0] == 3: + # Avoid a deprecation warning + from _imp import is_builtin +else: + from imp import is_builtin + class ellipsis(object): def __repr__(self): return "..." @@ -163,7 +169,8 @@ class Reloader(object): if getattr(mod, "__file__", None) and not os.path.isdir(mod.__file__): ending = os.path.splitext(mod.__file__)[-1] return ending not in (".py", ".pyc", ".pyo", ".pyi") - return False + # Python 2 leaves lots of empty crap in sys.modules + return bool(hasattr(mod, "__name__") and is_builtin(mod.__name__)) def update(self): """ -- cgit v1.2.3 From 49517d06cb09e36ecf00228bc8fa862a722842ed Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sat, 8 May 2021 16:06:23 +0200 Subject: py3.10-prep: reset the type cache after feature switching [ChangeLog][PySide6] Feature switching needs to reset the internal type cache. This was an omittion that becomes relevant in Python 3.10 . When using feature switching in Python 3.10, there were funny effects where switched and un-switched versions appeared to co-exist. It turned out that we were hit by function caching that is now implemented for the LOAD_ATTR opcode. It was not known that caching would happen at all for PySide classes because we don't use Py_TPFLAGS_VALID_VERSION_TAG. But actually, this flag is used internally by Python to do some optimizations, and we just have to notify the interpreter of type changes by PyType_Modified(). Task-number: PYSIDE-1436 Change-Id: Ie8a73f62bd6e9b8156b8ea23626fabd44700158b Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 3a2b7c6f88bba04d8b7ddb571163d23c15c36a4f) Reviewed-by: Christian Tismer --- sources/pyside2/libpyside/feature_select.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/pyside2/libpyside/feature_select.cpp b/sources/pyside2/libpyside/feature_select.cpp index dd8a11ee4..f47a6484d 100644 --- a/sources/pyside2/libpyside/feature_select.cpp +++ b/sources/pyside2/libpyside/feature_select.cpp @@ -390,6 +390,8 @@ static inline PyObject *SelectFeatureSet(PyTypeObject *type) if (!SelectFeatureSetSubtype(sub_type, select_id)) break; } + // PYSIDE-1436: Clear all caches for the type and subtypes. + PyType_Modified(type); } return type->tp_dict; } -- cgit v1.2.3 From c77bed5125660d6ad173321e1e40b6220795a976 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sat, 8 May 2021 16:06:23 +0200 Subject: py3.10-prep: Fix parser.py for changed typing module The typing module has subtle changes that are not even documented: Typing types now have a __name__ attribute. That confused the parser of the pyi generator because suddenly stingizing Callable[..., Optional[str]] resulted in Callable[..., Optional] because of special rules that return the generic name of a typing type, which was very unexpected. Finding this bug took a lot of debugging of the recursive `_resolve_type` function. We finally move the debugging_aid string as a function into lib/tool.py, because this was very helpful. Some changes are not valid in 5.15, because there were other modification in 6.x source code, like f-string, and some Qt install dir struncture, like Qt/resources. [ChangeLog][shiboken6] The parser for .pyi files needed an update because of undocumented changes in typing.py for Python 3.10 . Task-number: PYSIDE-1436 Change-Id: I3b8f2c1aa52a23014a8a915a0c677af96dfc536f Reviewed-by: Christian Tismer (cherry picked from commit 2530cb3f165ac02b8f7132e3f5ab4f7f6896dbd9) Reviewed-by: Cristian Maureira-Fredes --- build_scripts/platforms/linux.py | 6 ------ build_scripts/platforms/macos.py | 6 ------ sources/pyside2/tests/registry/scrape_testresults.py | 16 ++++++++-------- .../shiboken2/libshiboken/signature/signature_extend.cpp | 2 +- .../files.dir/shibokensupport/signature/lib/tool.py | 8 ++++++++ .../files.dir/shibokensupport/signature/parser.py | 15 +++------------ 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/build_scripts/platforms/linux.py b/build_scripts/platforms/linux.py index 712739e05..be71660c9 100644 --- a/build_scripts/platforms/linux.py +++ b/build_scripts/platforms/linux.py @@ -105,12 +105,6 @@ def prepare_standalone_package_linux(self, vars): recursive=False, vars=vars) - copydir("{qt_prefix_dir}/resources", - "{st_build_dir}/{st_package_name}/Qt/resources", - filter=None, - recursive=False, - vars=vars) - if copy_plugins: # /plugins/* -> /{st_package_name}/Qt/plugins copydir("{qt_plugins_dir}", diff --git a/build_scripts/platforms/macos.py b/build_scripts/platforms/macos.py index 7932db337..6f58ea222 100644 --- a/build_scripts/platforms/macos.py +++ b/build_scripts/platforms/macos.py @@ -160,12 +160,6 @@ def prepare_standalone_package_macos(self, vars): recursive=False, vars=vars) - copydir("{qt_prefix_dir}/resources", - "{st_build_dir}/{st_package_name}/Qt/resources", - filter=None, - recursive=False, - vars=vars) - # Fix rpath for WebEngine process executable. qt_libexec_path = "{st_build_dir}/{st_package_name}/Qt/libexec".format(**vars) binary = "QtWebEngineProcess" diff --git a/sources/pyside2/tests/registry/scrape_testresults.py b/sources/pyside2/tests/registry/scrape_testresults.py index c5c0e8689..56bb8058c 100644 --- a/sources/pyside2/tests/registry/scrape_testresults.py +++ b/sources/pyside2/tests/registry/scrape_testresults.py @@ -188,7 +188,7 @@ def write_data(name, text): lines.pop() text = "\n".join(lines) + "\n" modname = re.search(r"'(..*?)'", text).group(1) - fn = os.path.join(test_path, f"{ts}-{name}-{modname}.py") + fn = os.path.join(test_path, "{}-{}-{}.py".format(ts, name, modname)) if os.path.exists(fn): # do not change the file, we want to skip it return @@ -321,31 +321,31 @@ def get_test_results(starturl): minutes, seconds = divmod(remainder, 60) runtime_formatted = '%d:%02d:%06.3f' % (hours, minutes, seconds) - print(f"Run time: {runtime_formatted}s") + print("Run time: {}s".format(runtime_formatted)) if ok: found = eval_data() - print(f"Successful scan, {found} new files.") + print("Successful scan, {} new files.".format(found)) if found: print("Please check if a git push is necessary.") if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - usage=dedent(f"""\ - {os.path.basename(my_name)} [-h] scan + usage=dedent("""\ + {} [-h] scan - Scan the COIN testresults website for embedded exists_{{platf}}_{{version}}_ci.py files. + Scan the COIN testresults website for embedded exists_{{}}_{{}}_ci.py files. Warning: On the first call, this script may take almost 30 minutes to run. Subsequent calls are *much* faster due to caching. - {os.path.basename(my_name)} [-h] eval + {} [-h] eval Enforces evaluation when a scan did not complete yet. For more information, see the file sources/shiboken2/libshiboken/signature_doc.rst - """)) + """.format(os.path.basename(my_name), platf, version, os.path.basename(my_name))) subparsers = parser.add_subparsers(dest="command", metavar="", title="required argument") # create the parser for the "scan" command parser_scan = subparsers.add_parser("scan", help="run the scan") diff --git a/sources/shiboken2/libshiboken/signature/signature_extend.cpp b/sources/shiboken2/libshiboken/signature/signature_extend.cpp index b21eb5b60..23c7e5d98 100644 --- a/sources/shiboken2/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken2/libshiboken/signature/signature_extend.cpp @@ -145,7 +145,7 @@ static PyObject *handle_doc(PyObject *ob, PyObject *old_descr) name = reinterpret_cast(ob_type_mod.object())->tp_name; PyObject *res{}; - if (handle_doc_in_progress || name == nullptr || strncmp(name, "PySide6.", 8) != 0) { + 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++; diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py index ef5d0f693..8562d3f57 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py @@ -29,6 +29,7 @@ On the function with_metaclass see the answer from Martijn Pieters on https://stackoverflow.com/questions/18513821/python-metaclass-understanding-the-with-metaclass """ +from inspect import currentframe from textwrap import dedent @@ -133,4 +134,11 @@ def with_metaclass(meta, *bases): return meta.__prepare__(name, bases) return type.__new__(metaclass, 'temporary_class', (), {}) + +# A handy tool that shows the current line number and indents. +def lno(level): + lineno = currentframe().f_back.f_lineno + spaces = level * " " + return "{}{}".format(lineno, spaces) + # eof diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py index ec77208c8..7682801de 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py @@ -25,10 +25,11 @@ import sys import re import warnings import types +import typing import keyword import functools from shibokensupport.signature.mapping import (type_map, update_mapping, - namespace, typing, _NotCalled, ResultVariable, ArrayLikeVariable) + namespace, _NotCalled, ResultVariable, ArrayLikeVariable) from shibokensupport.signature.lib.tool import (SimpleNamespace, build_brace_pattern) @@ -204,7 +205,7 @@ def _resolve_arraytype(thing, line): def to_string(thing): if isinstance(thing, str): return thing - if hasattr(thing, "__name__"): + if hasattr(thing, "__name__") and thing.__module__ != "typing": dot = "." in str(thing) name = get_name(thing) return thing.__module__ + "." + name if dot else name @@ -221,16 +222,6 @@ def handle_matrix(arg): return eval(result, namespace) -debugging_aid = """ -from inspect import currentframe - -def lno(level): - lineno = currentframe().f_back.f_lineno - spaces = level * " " - return "{lineno}{spaces}".format(**locals()) -""" - - def _resolve_type(thing, line, level, var_handler): # Capture total replacements, first. Happens in # "PySide2.QtCore.QCborStreamReader.StringResult[PySide2.QtCore.QByteArray]" -- cgit v1.2.3 From 6eba1c4e5cd44dde936fb2dac3d65879415ed95a Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sat, 8 May 2021 16:06:23 +0200 Subject: py3.10-prep: Finally support Python 3.10 After the major problems are solved in py3.10-prep: re-implement zip import py3.10-prep: reset the type cache after feature switching py3.10-prep: Fix parser.py for changed typing module , there are only some minor changes left to do. One thing is still not clear: * Unsolved: In time_test.py, the last two tests work but crash at shutdown. It is not yet clear if this is a PySide or Python error. This will crash Python 3.10 if not solved until the release. [ChangeLog][PySide6] Support Python 3.10. This is by 99% solved. Looking for a crash with unknown origin. Fixes: PYSIDE-1436 Change-Id: I94cffa7ed16a2651e09924fe5babc188b1b4c2b8 Reviewed-by: Christian Tismer (cherry picked from commit 81e9cff884d6b03cdf64a5dd6ec6564d99177e0c) Reviewed-by: Cristian Maureira-Fredes --- build_scripts/config.py | 1 + sources/pyside2/tests/QtWidgets/signature_test.py | 5 +++-- sources/shiboken2/libshiboken/pep384impl.cpp | 8 +++++--- sources/shiboken2/libshiboken/pep384impl.h | 7 ++++++- sources/shiboken2/libshiboken/sbkstring.cpp | 2 +- .../shibokenmodule/files.dir/shibokensupport/signature/mapping.py | 1 + sources/shiboken2/tests/samplebinding/time_test.py | 1 + 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/build_scripts/config.py b/build_scripts/config.py index b1b32068d..7ff155c5f 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -93,6 +93,7 @@ class Config(object): 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ] self.setup_script_dir = None diff --git a/sources/pyside2/tests/QtWidgets/signature_test.py b/sources/pyside2/tests/QtWidgets/signature_test.py index 57fcf3874..cacb576d7 100644 --- a/sources/pyside2/tests/QtWidgets/signature_test.py +++ b/sources/pyside2/tests/QtWidgets/signature_test.py @@ -65,8 +65,9 @@ class PySideSignatureTest(unittest.TestCase): for thing in obj.__signature__: self.assertEqual(type(thing), inspect.Signature) sm = PySide2.QtWidgets.QApplication.__dict__["palette"] - self.assertFalse(callable(sm)) - self.assertEqual(sm.__func__, obj) + # PYSIDE-1436: staticmethod is a callable since Python 3.10 + # Instead of checking callable(sm), we check the type: + self.assertEqual(type(sm), staticmethod) self.assertTrue(hasattr(sm, "__signature__") and sm.__signature__ is not None) diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index 8bdd6914e..629d5d84c 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -736,11 +736,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 2c8a2d481..a12be1fee 100644 --- a/sources/shiboken2/libshiboken/pep384impl.h +++ b/sources/shiboken2/libshiboken/pep384impl.h @@ -22,6 +22,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" { @@ -309,7 +314,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 e63a68c6d..cc8d4a6ec 100644 --- a/sources/shiboken2/libshiboken/sbkstring.cpp +++ b/sources/shiboken2/libshiboken/sbkstring.cpp @@ -229,7 +229,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/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index 8dce12a3a..fed68097e 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -289,6 +289,7 @@ type_map.update({ "zero(object)": None, "zero(str)": "", "zero(typing.Any)": None, + "zero(Any)": None, }) type_map.update({ diff --git a/sources/shiboken2/tests/samplebinding/time_test.py b/sources/shiboken2/tests/samplebinding/time_test.py index f8b35e7b7..3b8f232c7 100644 --- a/sources/shiboken2/tests/samplebinding/time_test.py +++ b/sources/shiboken2/tests/samplebinding/time_test.py @@ -130,6 +130,7 @@ class TimeTest(unittest.TestCase): result = time.somethingCompletelyDifferent(1, 2, ImplicitConv.CtorOne) self.assertEqual(result, Time.ThreeArgs) + # PYSIDE-1436: These tests crash at shutdown due to `assert(Not)?Equal`. def testCompareWithPythonTime(self): time = Time(12, 32, 5) py = datetime.time(12, 32, 5) -- cgit v1.2.3 From 4f2e2bf45858906e788f828c955643fef13414a9 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sat, 21 Aug 2021 19:13:46 +0200 Subject: py3.10-prep: Fix a binary operator bug in cppgenerator.py The cppgenerator produced on binary flag operators only checks for cppArg but not for cppSelf. This is wrong, because arguments are sometimes swapped on operator calls. This was recognized in a debug Python build on Python 3.10 . The error checking of this version has a lot improved. [ChangeLog][shiboken6] Binary flags operators did check cppArg only, but not cppSelf. This is necessary when arguments are swapped. Recognized on Python 3.10 due to improved error checks in debug mode. Task-number: PYSIDE-1436 Change-Id: If14e295e6a5a55a6b648c711b7a934733858636a Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 7034d2ff83248cf9f1a959fdeabf47e5d20c8df8) Reviewed-by: Christian Tismer --- sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 5a80e4893..0a8db80f6 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -5223,6 +5223,10 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEn << ">(int(PyLong_AsLong(self)));\n"; s << INDENT << "cppArg = static_cast<" << flagsEntry->originalName() << ">(int(PyLong_AsLong(" << PYTHON_ARG << ")));\n"; + // PYSIDE-1436: Need to error check self as well because operators are used + // sometimes with swapped args. + s << INDENT << "if (PyErr_Occurred())\n" << INDENT + << "return nullptr;\n"; s << "#else\n"; s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName() << ">(int(PyInt_AsLong(self)));\n"; -- cgit v1.2.3 From 9eed5f64b2d56a0c3dc0d7656cdbcbb792bbffeb Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 20 Aug 2021 18:18:57 +0200 Subject: py3.10-prep: Fix a very old refcounting error in time_test.py Since 2012-03-08, there was a refcounting error in the typesystem_sample.xml file at . The boolean function results were not refcounted. (Commit 7b731d702c64d172e192aa1876e4a6fade6c38d7) This bug was hard to find because nobody expects a failure in the testing code, and the error shows up at the very end in the finalization code, totally unrelated to the error location. In order to find it, the setting `PYTHONMALLOC=malloc` was needed, because otherwise we got a Python memory dump but no traceback. Then, Python was modified and code was inserted in the various involved `code_dealloc`, `tupledealloc` and `object_dealloc` functions that printed the involved refcounts and types before performing the actual deallocation. This bug actually was of no harm since only the wrong test was involved. It was very misleading because there were quite some changes to the `datetime` module in Python 3.10 . But the bug was nothing but a dormant refcounting error. [ChangeLog][shiboken6] A very old refcounting bug from 2012 in the sample XML lead to a crash in Python 3.10 . This bug was found because the refcounting of Python is more exact, now. Task-number: PYSIDE-1436 Change-Id: I4363aae48e23f8ccdbd85c30654a44edbd69e516 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 2af6ac20de365116b52b65c6c34cfd6c536c23df) Reviewed-by: Christian Tismer --- sources/shiboken2/tests/samplebinding/typesystem_sample.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml index 595afb9ae..70fabcf73 100644 --- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml +++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml @@ -1953,6 +1953,7 @@ %PYARG_0 = Py_False; else %PYARG_0 = Py_True; + Py_INCREF(%PYARG_0); } @@ -1970,6 +1971,7 @@ %PYARG_0 = Py_True; else %PYARG_0 = Py_False; + Py_INCREF(%PYARG_0); } -- cgit v1.2.3 From f3771d4e83a72a56c1516fbd2c19c46084ee3d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Tue, 28 Sep 2021 11:28:14 +0200 Subject: Python 3.10: add wheel identifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I97b323d5055c30f782f62b85e734eb9f0e33f7b3 Reviewed-by: Simo Fält (cherry picked from commit 2fb82b5cd3ee1db9234e038759bd0e3cda9ca40b) Reviewed-by: Christian Tismer --- build_scripts/config.py | 2 +- build_scripts/wheel_override.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build_scripts/config.py b/build_scripts/config.py index 7ff155c5f..00cbd3fc9 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -136,7 +136,7 @@ class Config(object): setup_kwargs['zip_safe'] = False setup_kwargs['cmdclass'] = cmd_class_dict setup_kwargs['version'] = package_version - setup_kwargs['python_requires'] = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.10" + setup_kwargs['python_requires'] = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11" if quiet: # Tells distutils / setuptools to be quiet, and only print warnings or errors. diff --git a/build_scripts/wheel_override.py b/build_scripts/wheel_override.py index 66141763b..3f3c12a2e 100644 --- a/build_scripts/wheel_override.py +++ b/build_scripts/wheel_override.py @@ -90,7 +90,7 @@ class PysideBuildWheel(_bdist_wheel, DistUtilsCommandMixin): limited_api_enabled = (OPTION["LIMITED_API"] == 'yes' and sys.version_info[0] >= 3) if limited_api_enabled: - self.py_limited_api = "cp35.cp36.cp37.cp38.cp39" + self.py_limited_api = "cp35.cp36.cp37.cp38.cp39.cp310" self._package_version = get_package_version() -- cgit v1.2.3 From 209d9ff229bd6870d7f684dad0495ef7bde5b75c Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Thu, 6 May 2021 11:07:19 +0200 Subject: Fix cmake argument for standalone macOS The command --build doesn't properly work when trying to do a standalone invocation, and complains that it's an unknown argument, since that's meant to invoke a build with ninja, make, etc, and not to get information related the path of libraries, -B should be used instead. Fixes: PYSIDE-1556 Change-Id: I4e64477032beba75c1210cb29093465f1c85bb6c Reviewed-by: Alexandru Croitor (cherry picked from commit 58ac9b4ca4e67db1480c03f3fc84948d2dcb793f) Reviewed-by: Christian Tismer --- build_scripts/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/main.py b/build_scripts/main.py index 461e5a712..c7e67ac12 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -1056,7 +1056,7 @@ class PysideBuild(_build, DistUtilsCommandMixin): OPTION["CMAKE"], "-L", # Lists variables "-N", # Just inspects the cache (faster) - "--build", # Specifies the build dir + "-B", # Specifies the build dir self.shiboken_build_dir ] out = run_process_output(cmake_cmd) -- cgit v1.2.3 From 8908687e5b8eb5f5d054d2a76b4d9e9a19cd38fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Wed, 5 Jan 2022 12:23:55 +0100 Subject: Add changelog for 5.15.8 Change-Id: I998edf104f6250676539f77ae34a3acaefa6bc9c Reviewed-by: Christian Tismer --- dist/changes-5.15.8 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 dist/changes-5.15.8 diff --git a/dist/changes-5.15.8 b/dist/changes-5.15.8 new file mode 100644 index 000000000..f3dac46e4 --- /dev/null +++ b/dist/changes-5.15.8 @@ -0,0 +1,41 @@ +Qt for Python 5.15.8 is a bug-fix release. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qtforpython/ + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* PySide2 * +**************************************************************************** + + - Backporting changes from PySide6 to enable Python 3.10 + - [PYSIDE-803] Allow threads in QtGui.QTextDocument.print_ + - [PYSIDE-1556] Fix cmake argument for standalone macOS + - [PYSIDE-1675] PySide6: Fix a bug in Slot.__call__ + - [PYSIDE-1703] Fix build with MSVC 19.29.30136 + - [PYSIDE-1710] signature: improve error handling for embedded applications + - [PYSIDE-1710] scriptable: make it work by default on macOS, too + - [PYSIDE-1715] PySide6: Fix crash when connecting slot after disconnecting + non-existent connection to same slot + - [PYSIDE-1716] PySide2: Add QSGRendererInterface + - [PYSIDE-1727] Signature: fix the __doc__ attribute of classes + +**************************************************************************** +* Shiboken2 * +**************************************************************************** + + - [PYSIDE-1710] Error handling was improved for embedded + applications and builtin modules are trusted as valid modules. + - [PYSIDE-1684] shiboken6: Do not crash when class cannot be found in the + overload sorter + - [PYSIDE-1697] shiboken6: Fix a leak in keyword arguments handling + -- cgit v1.2.3 From 843bb81dcf03f80de9c51cfa4c32e31c4e207deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Wed, 5 Jan 2022 15:28:43 +0100 Subject: py3.10-prep: Fix parser.py for changed typing module amend Undo wrong changes related to the Qt/resources copying. Change-Id: I8ce54cce07a3aeceb9ae4621dd2512ecb2a6c1d1 Reviewed-by: Cristian Maureira-Fredes --- build_scripts/platforms/linux.py | 6 ++++++ build_scripts/platforms/macos.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/build_scripts/platforms/linux.py b/build_scripts/platforms/linux.py index be71660c9..712739e05 100644 --- a/build_scripts/platforms/linux.py +++ b/build_scripts/platforms/linux.py @@ -105,6 +105,12 @@ def prepare_standalone_package_linux(self, vars): recursive=False, vars=vars) + copydir("{qt_prefix_dir}/resources", + "{st_build_dir}/{st_package_name}/Qt/resources", + filter=None, + recursive=False, + vars=vars) + if copy_plugins: # /plugins/* -> /{st_package_name}/Qt/plugins copydir("{qt_plugins_dir}", diff --git a/build_scripts/platforms/macos.py b/build_scripts/platforms/macos.py index 6f58ea222..7932db337 100644 --- a/build_scripts/platforms/macos.py +++ b/build_scripts/platforms/macos.py @@ -160,6 +160,12 @@ def prepare_standalone_package_macos(self, vars): recursive=False, vars=vars) + copydir("{qt_prefix_dir}/resources", + "{st_build_dir}/{st_package_name}/Qt/resources", + filter=None, + recursive=False, + vars=vars) + # Fix rpath for WebEngine process executable. qt_libexec_path = "{st_build_dir}/{st_package_name}/Qt/libexec".format(**vars) binary = "QtWebEngineProcess" -- cgit v1.2.3 From b9cf35960e98adf9af7c4ea2cc09bfbdadf4f71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo=20F=C3=A4lt?= Date: Thu, 6 Jan 2022 15:37:07 +0200 Subject: Pin qt5#lts-5.15.8 as dependency and bump version numbers Change-Id: I73ea287ee3e655406e346d9c86114dec269efffc Reviewed-by: Friedemann Kleint --- coin/dependencies.yaml | 2 +- sources/pyside2/pyside_version.py | 2 +- sources/shiboken2/shiboken_version.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/coin/dependencies.yaml b/coin/dependencies.yaml index 8eaa2318f..c9df27bbb 100644 --- a/coin/dependencies.yaml +++ b/coin/dependencies.yaml @@ -1,6 +1,6 @@ product_dependency: ../../qt/tqtc-qt5.git: - ref: "tqtc/lts-5.15" + ref: "715f5bca3972b1841701f4ef10b7a582a1be2723" dependency_source: supermodule dependencies: [ "../../qt/qt3d", diff --git a/sources/pyside2/pyside_version.py b/sources/pyside2/pyside_version.py index 390f4cdc5..6bb157ef9 100644 --- a/sources/pyside2/pyside_version.py +++ b/sources/pyside2/pyside_version.py @@ -21,7 +21,7 @@ major_version = "5" minor_version = "15" -patch_version = "6" +patch_version = "8" # For example: "a", "b", "rc" # (which means "alpha", "beta", "release candidate"). diff --git a/sources/shiboken2/shiboken_version.py b/sources/shiboken2/shiboken_version.py index 390f4cdc5..6bb157ef9 100644 --- a/sources/shiboken2/shiboken_version.py +++ b/sources/shiboken2/shiboken_version.py @@ -21,7 +21,7 @@ major_version = "5" minor_version = "15" -patch_version = "6" +patch_version = "8" # For example: "a", "b", "rc" # (which means "alpha", "beta", "release candidate"). -- cgit v1.2.3