Commit 3e35db7
committed
gh-136640: Correct the description of AST location attributes
Eight of the types generated from ``Parser/Python.asdl`` carry the
``lineno``/``col_offset``/``end_lineno``/``end_col_offset`` attributes --
``stmt``, ``expr``, ``excepthandler``, ``arg``, ``keyword``, ``alias``,
``pattern`` and ``type_param`` -- but the documentation named only
``ast.expr`` and ``ast.stmt``.
The same block also stated that the end positions are always optional.
That holds for the six types that declare them as ``int?`` in the
grammar; ``pattern`` and ``type_param`` declare them as ``int``, and
compiling a tree whose ``pattern`` or ``type_param`` node is missing
``end_lineno`` raises ``TypeError``.
The first paragraph follows the wording approved in GH-136868 and the
two review suggestions on it, except that it keeps the original
"Instances of": the classes themselves expose nothing, so
``hasattr(ast.Name, 'lineno')`` is false. The cross-reference uses
``:ref:``, matching the rest of the file.1 parent 6893326 commit 3e35db7
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
| |||
0 commit comments