From c9f522f082485186dcd8be80186e3c11b55f2b77 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 12 Apr 2019 10:58:02 +0200 Subject: Ensure that signature strings never overflow again The signature module used to use large strings with the signatures of all functions in a class. This can lead to an overflow in MSVC, because the maximum string length funnily still is 32K unicode characters. This patch solves that by using a single string per function. Instead of a huge string, a list of strings is passed to each class. To prevent any runtime increase, the string list creation is deferred until the actual usage. At initialization time only a ssize_t holding the structure address is passed. As a result, the signature module should be even slightly faster. Task-number: PYSIDE-955 Change-Id: I99faf942a3cca03456928b8aec5e8a4b9924b8b2 Reviewed-by: Friedemann Kleint --- .../files.dir/shibokensupport/signature/parser.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'sources/shiboken2/shibokenmodule/files.dir') diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py index 09e78f1b0..72ca35757 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py @@ -224,7 +224,6 @@ def _resolve_type(thing, line): return _resolve_value(thing, None, line) def calculate_props(line): - line = line.strip() res = _parse_line(line) arglist = res["arglist"] annotations = {} @@ -257,8 +256,7 @@ def calculate_props(line): props["multi"] = res["multi"] return props -def fixup_multilines(sig_str): - lines = list(line.strip() for line in sig_str.strip().splitlines()) +def fixup_multilines(lines): res = [] multi_lines = [] for line in lines: @@ -282,15 +280,11 @@ def fixup_multilines(sig_str): res.append(line) return res -def pyside_type_init(typemod, sig_str): +def pyside_type_init(type_key, sig_strings): dprint() - if type(typemod) is types.ModuleType: - dprint("Initialization of module '{}'".format(typemod.__name__)) - else: - dprint("Initialization of type '{}.{}'".format(typemod.__module__, - typemod.__name__)) + dprint("Initialization of type key '{}'".format(type_key)) update_mapping() - lines = fixup_multilines(sig_str) + lines = fixup_multilines(sig_strings) ret = {} multi_props = [] for line in lines: -- cgit v1.2.3