New submission from mpheath <[email protected]>:
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:
"""Replace all chars except '\f\t' in a line with spaces."""
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:
"Replace all chars except '\f\t' in a line with spaces."
I would expect the source to be:
"""Replace all chars except '\\f\\t' in a line with spaces."""
or perhaps a raw string:
r"""Replace all chars except '\f\t' in a line with spaces."""
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 .
Python 3.7.4 3.7/Lib/ast.py does not have the function _pad_whitespace as it
appears major code changes occurred in the ast module with Python 3.8.0.
----------
messages: 361203
nosy: mpheath
priority: normal
severity: normal
status: open
title: Escape sequences in doc string of ast._pad_whitespace
type: behavior
versions: Python 3.8, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39524>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com