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
Escape sequences in doc string of ast._pad_whitespace #83705
Comments
In the ast module, a function named _pad_whitespace has a doc string with escape sequences of \f and \t. The current doc string from Lib/ast.py:305 is:
Example of doc string output in a REPL: Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> import inspect
>>> inspect.getdoc(ast._pad_whitespace)
"Replace all chars except '\x0c ' in a line with spaces."
>>> The \x0c is the formfeed and the ' ' (5 spaces) was the tab. It is my understanding that the output should be:
I would expect the source to be:
or perhaps a raw string:
The current Lib/ast.py:305 is Python 3.9.0 alpha 3 though the issue is also in Python 3.8.0 and 3.8.1 with 3.8/Lib/ast.py:227 . |
Correction: Python 3.8.0 and 3.8.1 with Lib/ast.py:277 Line 227 is invalid and 277 is correct. |
Correction: Python 3.8.0 and 3.8.1 with 3.8/Lib/ast.py:277 Line 227 is invalid and 277 is correct and forgot to add 3.8 prefix. Sorry. |
I think this would be an improvement, and an good issue for a newcomer. I'd vote for the r-string, but it doesn't really matter. |
But in both cases the 'Output' will contain '\\': |
I have submitted 2 Pull Requests. One for 3.9 and the other for 3.8. Only way I knew was to create 2 separate branches to checkout, linked to version tags to get the correct patches for ast.py. Hope is OK. |
The backport of the patch to 3.8 has failed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: