-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
Hi there,
In the new version 5.0 alpha1 there is a difference in parsing code with robot.api.get_model
for try/except statements.
Given this piece of code:
import ast
from robot.api.parsing import get_model
test = r"""
*** Test Cases ***
first
Log hi
TRY
Fail huch
EXCEPT huch AS ${a}
Log except ${a}
FINALLY
Log finally
END
"""
for node in ast.walk(get_model(test, data_only=False)):
if node.errors:
print(node.errors)
If I set the data_only parameter to False (which is the default value) i will get:
("EXCEPT's AS marker must be second to last.", "EXCEPT's AS variable '\n' is invalid.")
which is not correct, because it is valid code. If I set the data_only parameter to True, then everything is ok.
I think the implementation is wrong in this case:
see here
if as_token is not self.tokens[-2]: |
The test for the AS token and the variable should not be done by index, because the tokens differs if we are parsing with data_only= False
mode.
Also I think the message EXCEPT's AS marker must be second to last.
is not really necessary, it should be enough to say that there is no variable or a wrong variable.
Metadata
Metadata
Assignees
Labels
No labels