aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/shibokenmodule/files.dir
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-11-06 14:53:53 +0100
committerChristian Tismer <tismer@stackless.com>2020-11-11 17:29:38 +0000
commit12c93597dd09c68e2d619e03f9867afbc56dcf48 (patch)
tree8fdf4cff22b88b1dbab209f744568923fc963c98 /sources/shiboken6/shibokenmodule/files.dir
parentce8dcd2c7755aa5272f484c0e475a1b65b8a01c3 (diff)
__feature__: provide useful error message when feature is active
Features seem to work quite good so far, but they clearly need much more testing. One of the problems is that error messages are produced, but the function name is not found and we get an ugly default error message. This is an efficient implementation that does all name mangling in the C code. A helper dict avoids linear search for properties. Task-number: PYSIDE-1019 Change-Id: Ic87c4a6e7dc2b2a251e809d6df0eb7fb9ca8021c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir')
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
index 264700ffa..7083fd1e6 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
@@ -61,11 +61,6 @@ from shibokensupport.signature import get_signature
from shibokensupport.signature.mapping import update_mapping, namespace
from textwrap import dedent
-try:
- import PySide6
-except ImportError:
- pass
-
def qt_isinstance(inst, the_type):
if the_type == float:
@@ -99,16 +94,15 @@ def matched_type(args, sigs):
def seterror_argument(args, func_name):
- update_mapping()
func = None
try:
func = eval(func_name, namespace)
except Exception as e:
- msg = f"Internal error evaluating {func_name}: {e}"
+ msg = f"Internal error evaluating {func_name}: " + str(e)
return TypeError, msg
sigs = get_signature(func, "typeerror")
if not sigs:
- msg = f"Missing signature: {func_name}({args})"
+ msg = f"{func_name}({args} is wrong (missing signature)"
return TypeError, msg
if type(sigs) != list:
sigs = [sigs]
@@ -118,7 +112,7 @@ def seterror_argument(args, func_name):
found = matched_type(args, sigs)
if found:
msg = dedent(f"""
- '{func_name}' called with wrong argument values:
+ {func_name!r} called with wrong argument values:
{func_name}{args}
Found signature:
{func_name}{found}
@@ -126,7 +120,7 @@ def seterror_argument(args, func_name):
return ValueError, msg
type_str = ", ".join(type(arg).__name__ for arg in args)
msg = dedent(f"""
- '{func_name}' called with wrong argument types:
+ {func_name!r} called with wrong argument types:
{func_name}({type_str})
Supported signatures:
""").strip()