Merge pull request #3694 from count-infinity/3692-parser-errors

Fixing funcparser issues
This commit is contained in:
Griatch 2025-01-18 11:13:47 +01:00 committed by GitHub
commit 6567f26615
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -339,6 +339,7 @@ class FuncParser:
# always store escaped characters verbatim
if curr_func:
infuncstr += char
curr_func.rawstr += char
else:
fullstr += char
escaped = False
@ -372,7 +373,8 @@ class FuncParser:
curr_func.open_lsquare = open_lsquare
curr_func.open_lcurly = open_lcurly
# we must strip the remaining funcstr so it's not counted twice
curr_func.rawstr = curr_func.rawstr[: -len(infuncstr)]
if len(infuncstr) > 0:
curr_func.rawstr = curr_func.rawstr[: -len(infuncstr)]
current_kwarg = ""
infuncstr = ""
double_quoted = -1

View file

@ -231,6 +231,8 @@ class TestFuncParser(TestCase):
("Test literal3 $typ($lit(1)aaa)", "Test literal3 <class 'str'>"),
("Test literal4 $typ(aaa$lit(1))", "Test literal4 <class 'str'>"),
("Test spider's thread", "Test spider's thread"),
("Test invalid syntax $a=$b", "Test invalid syntax $a=$b"),
(r"Test invalid syntax $a\= b", "Test invalid syntax $a= b"),
]
)
def test_parse(self, string, expected):