Skip to content

Minor change to LOAD_ATTR Opcode in 3.13 not documented #138402

@CarrBen

Description

@CarrBen

Documentation

The order that items are pushed to the stack by LOAD_ATTR changed in 3.13, but this is not mentioned in the dis module documentation for the LOAD_ATTR Opcode.

Further Details

For the LOAD_ATTR Opcode, the following change from 3.12 is documented

Changed in version 3.12: If the low bit of namei is set, then a NULL or self is pushed to the stack before the attribute or unbound method respectively.

And this can be seen in frameobject.c: https://github.com/python/cpython/blob/3.12/Objects/frameobject.c#L422 where NULL is pushed before Object.

However, in 3.13 this has changed, presumably due to changes to the CALL Opcode;

Changed in version 3.13: The callable now always appears at the same position on the stack.

And for LOAD_ATTR the NULL is now pushed to the stack after the attribute or unbound method.

This ordering change can be seen in frameobject.c for 3.13: https://github.com/python/cpython/blob/3.13/Objects/frameobject.c#L1280 where Object is now pushed before NULL.

Suggested Resolution

My suggestion would be adding something like this to the LOAD_ATTR documentation;

Changed in version 3.13: When the low bit of namei is set, NULL or self is pushed to the stack after the attribute or unbound method respectively.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions