-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python: provide informative exception for trailing escapes in tables #241
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! Will go with your latest preference following the considerations I have added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I had a look at the Javascript and Ruby implementations and they're just as confusing. Java was the odd one out. So this is a good solution.
What is weird though, they should have the same problem because both JS and Ruby do something equivalent to:
elsif char == '\\'
char = row[col]
And that should result in char being undefined
. Which is rendered to string as undefined
in JS atleast.
"hello " + "cucumber"[8]
"hello undefined"
Fixing this it outside the scope of this PR though.
🤔 What's changed?
With the Python implementation:
|
), escape characters, etc.n
,t
), when an escape character is detected\\
an additionalnext
call is made to grab the next character\\
) would be stripped, there would not be a following character and aStopIteration
error is raised.gherkin/python/gherkin/gherkin_line.py
Lines 39 to 62 in b055261
By defaulting the iterator to an empty string, when there is a trailing escape character, the trailing escape character will not trigger a
StopIteration
error and subsequent code will appropriately raise aninconsistent cell count
error message.⚡️ What's your motivation?
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.