diff options
author | Christian Tismer <tismer@stackless.com> | 2020-11-06 14:53:53 +0100 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-11-06 15:03:08 +0000 |
commit | 89f5c75386c4ae7c439435e3e78fb7a22d76d3ad (patch) | |
tree | cbf07ce9cd1ea4b56dce0756d7908101e6e9760e /sources/shiboken6/shibokenmodule/files.dir/shibokensupport | |
parent | 6f4f64f876928e637ce38eeb986c22c8b6fccd7e (diff) |
signature: provide error messages for unsupported function types
Since class properties are now developed, we now have the
case that class methods can produce errors without having
a valid signature, yet.
Signatures for class methods will be implemented eventually.
Before that happens, we provide a default error message
which shows the given arguments.
This is sufficient for the moment, because errors in class methods
can currently be created by class property setters only which have
a quite trivial signature.
Task-number: PYSIDE-510
Change-Id: I6397da114cedd628ba19c86b153e60497a0b4ddd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir/shibokensupport')
-rw-r--r-- | sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py index df7a0bca8..305509d77 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py @@ -63,6 +63,11 @@ 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: @@ -101,9 +106,12 @@ def seterror_argument(args, func_name): try: func = eval(func_name, namespace) except Exception as e: - msg = "Internal error evaluating " + func_name + " :" + str(e) + msg = f"Internal error evaluating {func_name}: {e}" return TypeError, msg sigs = get_signature(func, "typeerror") + if not sigs: + msg = f"Missing signature: {func_name}({args})" + return TypeError, msg if type(sigs) != list: sigs = [sigs] if type(args) != tuple: @@ -129,9 +137,11 @@ def seterror_argument(args, func_name): # We don't raise the error here, to avoid the loader in the traceback. return TypeError, msg + def check_string_type(s): return isinstance(s, str) + def make_helptext(func): existing_doc = func.__doc__ sigs = get_signature(func) @@ -144,7 +154,7 @@ def make_helptext(func): except AttribureError: func_name = func.__func__.__name__ sigtext = "\n".join(func_name + str(sig) for sig in sigs) - msg = sigtext + "\n\n" + existing_doc if check_string_type(existing_doc) else sigtext + msg = f"{sigtext}\n\n{existing_doc}" if check_string_type(existing_doc) else sigtext return msg # end of file |