aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-12-13 15:00:37 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-16 12:53:01 +0000
commit1f0a6975703154e3df5c43cd0f54a56c0e0250e6 (patch)
tree8a62c0b61f5f8dbaf0883b405dd8f2339c2b90d4 /sources/shiboken6
parentc41803fc2699195609759b4d1e64aff1f1dedf4f (diff)
signature: Fix the parser regex for Qt6
Our parser regex handled everything but no single quotes. In Qt6, single quotes appeared with a backslash escape. Errors will no longer give a warning but raise a SystemError from now on, because syntax errors in the parser are not tolerable. Task-number: PYSIDE-510 Change-Id: I6790d4aa73b507160b0c3107c2aa665fe6aae49d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit be04c2df4202bcf2086348380da91fcfb28397d6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources/shiboken6')
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py27
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py4
2 files changed, 17 insertions, 14 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py
index 946067fed..83da63891 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py
@@ -91,25 +91,27 @@ def build_brace_pattern(level, separators=""):
avoiding this problem completely. It might be considered to switch to
such an engine if the external module is not a problem.
"""
- def escape(str):
- return "".join("\\" + c for c in str)
+ def escape(txt):
+ return "".join("\\" + c for c in txt)
- ro, rc = round = "()"
+ ro, rc = round_ = "()"
so, sc = square = "[]"
co, cc = curly = "CD" # we insert "{}", later...
ao, ac = angle = "<>"
- qu, bs = '"', "\\"
- all = round + square + curly + angle
+ q2, bs, q1 = '"', "\\", "'"
+ allpat = round_ + square + curly + angle
__ = " "
- ro, rc, so, sc, co, cc, ao, ac, separators, qu, bs, all = map(
- escape, (ro, rc, so, sc, co, cc, ao, ac, separators, qu, bs, all))
+ ro, rc, so, sc, co, cc, ao, ac, separators, q2, bs, q1, allpat = map(
+ escape, (ro, rc, so, sc, co, cc, ao, ac, separators, q2, bs, q1, allpat))
- no_brace_sep_q = fr"[^{all}{separators}{qu}{bs}]"
- no_quote = fr"(?: [^{qu}{bs}] | {bs}. )*"
+ no_brace_sep_q = fr"[^{allpat}{separators}{q2}{bs}{q1}]"
+ no_quot2 = fr"(?: [^{q2}{bs}] | {bs}. )*"
+ no_quot1 = fr"(?: [^{q1}{bs}] | {bs}. )*"
pattern = dedent(r"""
(
(?: {__} {no_brace_sep_q}
- | {qu} {no_quote} {qu}
+ | {q2} {no_quot2} {q2}
+ | {q1} {no_quot1} {q1}
| {ro} {replacer} {rc}
| {so} {replacer} {sc}
| {co} {replacer} {cc}
@@ -117,10 +119,11 @@ def build_brace_pattern(level, separators=""):
)+
)
""")
- no_braces_q = f"[^{all}{qu}{bs}]*"
+ no_braces_q = f"[^{allpat}{q2}{bs}{q1}]*"
repeated = dedent(r"""
{indent} (?: {__} {no_braces_q}
- {indent} | {qu} {no_quote} {qu}
+ {indent} | {q2} {no_quot2} {q2}
+ {indent} | {q1} {no_quot1} {q1}
{indent} | {ro} {replacer} {rc}
{indent} | {so} {replacer} {sc}
{indent} | {co} {replacer} {cc}
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index b00419362..49c0ca5be 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -114,8 +114,8 @@ def _parse_line(line):
if idx == 0 and tokens[0] == "self":
tokens = 2 * tokens # "self: self"
else:
- warnings.warn('Invalid argument "{}" in "{}".'.format(arg, line))
- continue
+ # This should never happen again (but who knows?)
+ raise SystemError(f'Invalid argument "{arg}" in "{line}".')
name, ann = tokens
if name in keyword.kwlist:
if LIST_KEYWORDS: