Skip to content

parser: dotted decorator names raise NameError #264

Open

Description

@drew-512

A decorator with a dotted name fails at runtime:

class C:
    def deco(self, f):
        return f

c = C()

@c.deco
def f():
    pass

On main (444ae5e):

NameError: "name 'c.deco' is not defined"

CPython 3.4 runs it. The parser turns the dotted name into one Name whose Id is the whole string, where CPython builds a Name plus one Attribute per component (ast_for_dotted_name in Python/ast.c). test_dotted in vm/tests/decorators.py is commented out because of it.

Go 1.27.1, darwin/arm64.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions