[issue39579] Attribute node in a decorator has wrong end_col_offset

Lysandros Nikolaou report at bugs.python.org
Fri Feb 7 09:44:54 EST 2020


New submission from Lysandros Nikolaou <lisandrosnik at gmail.com>:

There is a problem with the end_col_offset of nested Attribute nodes in decorators. For example, parsing

@a.b.c
def f(): pass

produces the following AST tree (part):

decorator_list=[
    Attribute(
        value=Attribute(
            value=Name(
                id="a",
                ctx=Load(),
                lineno=1,
                col_offset=1,
                end_lineno=1,
                end_col_offset=2,
            ),
            attr="b",
            ctx=Load(),
            lineno=1,
            col_offset=1,
            end_lineno=1,
            *end_col_offset=6*,
        ),
        attr="c",
        ctx=Load(),
        lineno=1,
        col_offset=1,
        end_lineno=1,
        end_col_offset=6,
    )
],

Note that the Attribute node with attr="b" has end_col_offset=6, while it should actually be 4.

----------
components: Interpreter Core
messages: 361595
nosy: gvanrossum, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Attribute node in a decorator has wrong end_col_offset
versions: Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39579>
_______________________________________


More information about the Python-bugs-list mailing list