aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-11-19 10:35:27 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-22 16:02:42 +0000
commitf83bd5cb4c9f2075b9e7a9dcf9046a9c6c489d7a (patch)
tree7658b89985420e9b2cec449585dfca8d65659b26
parentf9f80d765f44da153034e8c254e8842498511aa5 (diff)
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 <Friedemann.Kleint@qt.io> (cherry picked from commit 2149a45fddeedea317dccbfe5e5b14e13888e5c9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/libshiboken/signature/signature.cpp3
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py4
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py4
3 files changed, 6 insertions, 5 deletions
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp
index 243f3e35f..a8a17ec14 100644
--- a/sources/shiboken6/libshiboken/signature/signature.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature.cpp
@@ -512,9 +512,10 @@ static PyObject *adjustFuncName(const char *func_name)
return nullptr;
// Run `eval` on the type string to get the object.
+ // PYSIDE-1710: If the eval does not work, return the given string.
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/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
index 0c1b72644..4c436eafd 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
@@ -104,8 +104,8 @@ def seterror_argument(args, func_name, info):
try:
func = eval(func_name, namespace)
except Exception as e:
- msg = f"Internal error evaluating {func_name}: " + str(e)
- return TypeError, msg
+ msg = f"Error evaluating `{func_name}`: {e}"
+ return type(e), msg
if info and type(info) is str:
err = TypeError
if info == "<":
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
index adcbad3d9..77a61380f 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
@@ -54,7 +54,7 @@ import typing
from pathlib import Path
from typing import TypeVar, Generic
-from shibokensupport.signature.lib.tool import with_metaclass
+from _imp import is_builtin
class ellipsis(object):
def __repr__(self):
@@ -179,7 +179,7 @@ class Reloader(object):
if getattr(mod, "__file__", None) and not Path(mod.__file__).is_dir():
ending = Path(mod.__file__).suffix
return ending not in (".py", ".pyc", ".pyo", ".pyi")
- return False
+ return bool(is_builtin(mod.__name__))
def update(self):
"""