aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/shibokenmodule/files.dir
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-11-18 18:25:07 +0100
committerChristian Tismer <tismer@stackless.com>2020-11-23 15:32:49 +0000
commitb6e57864e5f4d470196f7425c631981de6d1aeb4 (patch)
tree8cebaae65fb291da2ef9fc89d87fa566243a65ef /sources/shiboken6/shibokenmodule/files.dir
parentb7c13a77f48baf5fdfa0371fe49a1a11e35ea8df (diff)
cppgenerator: rework keyword handling regarding unknown keywords
PySide has a distinction between functions with simple arguments and functions with keyword arguments for optional keywords. When a function has keywords specified in one or more signature branch, it gets the METH_KEYWORDS flag. In this case, it is checked that no argument is given positional and per keyword at the same time. Completely forgotten was to check which keywords are allowed in that branch, if at all. The problem was much complicated because constructors can contain extra signals and properties. At the same time, all further error messages are generated with Python. This adds necessary flexibility when features are active. All PyBuildValue objects were refcount leaking. That has been replaced by static createStaticString expressions. The `argNames` structure is no longer needed by the improved algorithm. Change-Id: Ic297912c47231720f61c7d4b79b46a1e376a9941 Fixes: PYSIDE-1305 Task-number: PYSIDE-1019 Pick-to: 5.15 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir')
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py21
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py4
2 files changed, 20 insertions, 5 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
index 7083fd1e6..76d2f2e9b 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
@@ -93,16 +93,31 @@ def matched_type(args, sigs):
return None
-def seterror_argument(args, func_name):
+def seterror_argument(args, func_name, info):
func = None
try:
func = eval(func_name, namespace)
except Exception as e:
msg = f"Internal error evaluating {func_name}: " + str(e)
return TypeError, msg
+ if info and type(info) is str:
+ err = TypeError
+ if info == "<":
+ msg = f"{func_name}(): not enough arguments"
+ elif info == ">":
+ msg = f"{func_name}(): too many arguments"
+ elif info.isalnum():
+ msg = f"{func_name}(): got multiple values for keyword argument '{info}'"
+ else:
+ msg = f"{func_name}(): {info}"
+ err = AttributeError
+ return err, msg
+ if info and type(info) is dict:
+ msg = f"{func_name}(): unsupported keyword '{tuple(info)[0]}'"
+ return TypeError, msg
sigs = get_signature(func, "typeerror")
if not sigs:
- msg = f"{func_name}({args} is wrong (missing signature)"
+ msg = f"{func_name}({args}) is wrong (missing signature)"
return TypeError, msg
if type(sigs) != list:
sigs = [sigs]
@@ -143,7 +158,7 @@ def make_helptext(func):
sigs = [sigs]
try:
func_name = func.__name__
- except AttribureError:
+ except AttributeError:
func_name = func.__func__.__name__
sigtext = "\n".join(func_name + str(sig) for sig in sigs)
msg = f"{sigtext}\n\n{existing_doc}" if check_string_type(existing_doc) else sigtext
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py
index 7b262783b..5a056aafd 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py
@@ -99,8 +99,8 @@ def create_signature(props, key):
return layout.create_signature(props, key)
# name used in signature.cpp
-def seterror_argument(args, func_name):
- return errorhandler.seterror_argument(args, func_name)
+def seterror_argument(args, func_name, info):
+ return errorhandler.seterror_argument(args, func_name, info)
# name used in signature.cpp
def make_helptext(func):