[issue39524] Escape sequences in doc string of ast._pad_whitespace
mpheath
report at bugs.python.org
Sat Feb 1 23:09:48 EST 2020
New submission from mpheath <mpheath at tpg.com.au>:
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 <report at bugs.python.org>
<https://bugs.python.org/issue39524>
_______________________________________
More information about the Python-bugs-list
mailing list