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. Fixes #2490
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 actually broad. The Python interpreter checks for all of them in it's implementation of the method. I incorporated checking for those characters.
A huge shout-out to @advikkabra for the clever testing. :tada:
Note
The Black formatter has automatically formatted the Python file I worked on. Please note that only change I made was the implementation of the isspace() method.
Last but not the least, I thoroughly enjoyed working on the issue. :smiley:
Fix:
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. Fixes #2490
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 actually broad. The Python interpreter checks for all of them in it's implementation of the method. I incorporated checking for those characters.A huge shout-out to @advikkabra for the clever testing. :tada:
Note
The Black formatter has automatically formatted the Python file I worked on. Please note that only change I made was the implementation of the
isspace()
method.Last but not the least, I thoroughly enjoyed working on the issue. :smiley: