python / python/cpython

Minor change to LOAD_ATTR Opcode in 3.13 not documented

オープン
#138,402 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

docs interpreter-core
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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
  • gh-138631

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Python 3.13 の dis モジュールのドキュメントにある LOAD_ATTR の項目から始め、issue でリンクされている 3.12 と 3.13 の frameobject.c の箇所とその文言を比較してください。変更を加える前に、リンクされている PR gh-138631 を確認してください。3.13 のスタック順序の変更が正確に記録されれば、ドキュメントは完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
1/5
見積もり時間
1時間未満
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。