From e3c16347247c11834e8c62d77ae6f88db7550b05 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Mon, 9 Jan 2023 11:03:41 +0100 Subject: [PATCH] Fix regression introduced with the latest changes to loadlib In Python 2, function type names from buiiltins.txt were entered into the tables as Unicode, causing the output module to promote strings to Unicode, and causing trouble further down the line. Entering them as str fixes the issue. Thanks a lot to @PeterStindberg for reporting the issue and providing a script that reproduces it. Fixes #21 --- lslopt/lslloadlib.py | 5 +++-- unit_tests/regression.suite/issue-21.lsl | 8 ++++++++ unit_tests/regression.suite/issue-21.out | 8 ++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 unit_tests/regression.suite/issue-21.lsl create mode 100644 unit_tests/regression.suite/issue-21.out diff --git a/lslopt/lslloadlib.py b/lslopt/lslloadlib.py index ca85447..6e13be8 100644 --- a/lslopt/lslloadlib.py +++ b/lslopt/lslloadlib.py @@ -104,7 +104,7 @@ def LoadLibrary(builtins = None, fndata = None): % (ubuiltins, linenum, argtyp)) bad = True break - args.append(argtyp) + args.append(u2str(argtyp)) if bad: continue name = match.group(2) @@ -123,7 +123,8 @@ def LoadLibrary(builtins = None, fndata = None): u" in %s, overwriting: %s" % (linenum, ubuiltins, name)) fn = getattr(lslfuncs, name, None) - functions[name] = {'Kind':'f', 'Type':typ, 'uns':True, + styp = None if typ is None else u2str(typ) + functions[name] = {'Kind':'f', 'Type':styp, 'uns':True, 'ParamTypes':args, 'NeedsData':True} if fn is not None: functions[name]['Fn'] = fn diff --git a/unit_tests/regression.suite/issue-21.lsl b/unit_tests/regression.suite/issue-21.lsl new file mode 100644 index 0000000..0adb843 --- /dev/null +++ b/unit_tests/regression.suite/issue-21.lsl @@ -0,0 +1,8 @@ +default +{ + state_entry() + { + llOwnerSay(llList2Key(llGetObjectDetails("", [1]),0)); + llOwnerSay(llChar(0xA1)); + } +} diff --git a/unit_tests/regression.suite/issue-21.out b/unit_tests/regression.suite/issue-21.out new file mode 100644 index 0000000..8cdc6b3 --- /dev/null +++ b/unit_tests/regression.suite/issue-21.out @@ -0,0 +1,8 @@ +default +{ + state_entry() + { + llOwnerSay((key)((string)llGetObjectDetails("", (list)1))); + llOwnerSay("ยก"); + } +}