aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-04-05 19:25:46 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-07 11:37:14 +0000
commit8bf8b4bd5a760c2089faeac00491dddcda2681ab (patch)
treebbf9290675c6c524013e424d93f2dca2466b7213
parent8d1a8885dd8f6397184889e4a49cb666fdd8b66c (diff)
signature: protect an unrecognized item from raising exceptions
A special case "std::optional" caused an exception at an unforeseen place, because "std" was not recognized in an eval. Turn this into another runtime warning. Also, the "std::optional" case was added as "typing.Optional" after applying und testing the above fix. Change-Id: I722ae463d133125e96ab09aeb38f21cdc2453d5b Fixes: PYSIDE-1538 Reviewed-by: Renato Araujo Oliveira Filho <renato.araujo@kdab.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 0a47111b454b8e1582d8595cadc348b61989ff29) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py4
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py12
2 files changed, 14 insertions, 2 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
index e6ad8d3d0..23c62717b 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
@@ -352,6 +352,10 @@ type_map.update({
"self" : "self",
})
+# PYSIDE-1538: We need to treat "std::optional" accordingly.
+type_map.update({
+ "std.optional": typing.Optional,
+ })
# The Shiboken Part
def init_Shiboken():
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index d737c2a54..84111cdd1 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -194,7 +194,7 @@ def _resolve_value(thing, valtype, line):
if res is not None:
type_map[thing] = res
return res
- warnings.warn(f"""pyside_type_init:
+ warnings.warn(f"""pyside_type_init:_resolve_value
UNRECOGNIZED: {thing!r}
OFFENDING LINE: {line!r}
@@ -275,7 +275,15 @@ def _resolve_type(thing, line, level, var_handler):
pieces.append(to_string(part))
thing = ", ".join(pieces)
result = f"{contr}[{thing}]"
- return eval(result, namespace)
+ # PYSIDE-1538: Make sure that the eval does not crash.
+ try:
+ return eval(result, namespace)
+ except Exception as e:
+ warnings.warn(f"""pyside_type_init:_resolve_type
+
+ UNRECOGNIZED: {result!r}
+ OFFENDING LINE: {line!r}
+ """, RuntimeWarning)
return _resolve_value(thing, None, line)