-
Notifications
You must be signed in to change notification settings - Fork 171
Add str.isspace()
method
#2586
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
Add str.isspace()
method
#2586
Conversation
I am adding the tests in a while. @Thirumalai-Shaktivel please see this. |
Also, Let's add some tests. |
Co-authored-by: Thirumalai Shaktivel <[email protected]>
@kmr-srbh Please mark it as ready for review when ready. |
The failing test, though unrelated, was causing disruption here. It was the one which checked for invalid literals like @Shaikh-Ubaid This PR is now ready. As far as the Unicode characters are concerned, they cannot be typed, but can appear when parsing strings or related work. They were added conforming to what Python calls a whitespace character. |
(TOKEN "identifier" i32) 28:30 | ||
(TOKEN "=") 32:32 | ||
(TOKEN "integer" 123) 34:37 | ||
(EOF) 38:38 |
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.
Also, I think this file needs to be remove manually.
Problem persists. Why does |
@Thirumalai-Shaktivel could you please look as to why the tests fail? The previous messages pointed to the null char I had declared for looping through the whitespace characters. I cannot understand why the tests fail now. Please guide me. |
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.
LGTM!
Fixes #2490.
#2490 gave wrong output due to the incorrect handling of the escape sequence '\f'. Escaping the sequence was handled, but unescaping was missed. This led to the string
" \t\n\v\f\r"
being transformed to" \t\n\v\\f\r"
in the AST. Note the extra "\" after "v". Hence, the answer in #2490 was thus 'not actually' wrong as non-whitespace and lowercase characters did exist.Fix
Improvement
Though the error in the above case was due to incorrect string handling, the
isspace()
method was actually not implemented correctly. The definition of a 'whitespace' character is very broad. The Python interpreter checks for all of them in it's implementation of the method. I incorporated checking for those characters.