`LOAD_SMALL_INT` has empty `argrepr` via `Bytecode`
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
When using Bytecode to disassemble some Python code I've noticed that the argrepr attribute of the Instruction holding a LOAD_SMALL_INT isn't populated. For example:
Python 3.14.0 (main, Oct 16 2025, 09:17:39) [Clang 17.0.0 (clang-1700.3.19.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from dis import Bytecode
>>> list(Bytecode("1"))
[
Instruction(
opname='RESUME',
opcode=128,
arg=0,
argval=0,
argrepr='',
offset=0,
start_offset=0,
starts_line=True,
line_number=0,
label=None,
positions=Positions(lineno=0, end_lineno=1, col_offset=0, end_col_offset=0),
cache_info=None
),
Instruction(
opname='LOAD_SMALL_INT',
opcode=94,
arg=1,
argval=1,
argrepr='', # <--- Empty string
offset=2,
start_offset=2,
starts_line=True,
line_number=1,
label=None,
positions=Positions(lineno=1, end_lineno=1, col_offset=0, end_col_offset=1),
cache_info=None
),
Instruction(
opname='RETURN_VALUE',
opcode=35,
arg=None,
argval=None,
argrepr='',
offset=4,
start_offset=4,
starts_line=False,
line_number=1,
label=None,
positions=Positions(lineno=1, end_lineno=1, col_offset=0, end_col_offset=1),
cache_info=None
)
]
I would have expected this to have the repr of the argument in there.
A quick and ignorant reading of dis.py suggests to me that there should be a change akin to this:
--- ../cpython/Lib/dis.py 2025-10-17 14:31:35.495151419 +0100
+++ my/dis.py 2025-10-17 14:43:26.650409153 +0100
@@ -586,7 +586,7 @@
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
argval = arg
- if deop in hasconst:
+ if deop in hasconst or deop == LOAD_SMALL_INT:
argval, argrepr = _get_const_info(deop, arg, self.co_consts)
elif deop in hasname:
if deop == LOAD_GLOBAL:
CPython versions tested on:
3.14
Operating systems tested on:
macOS
Linked PRs
- gh-140258
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lib/dis.py の Bytecode の引数処理ロジックから始め、list(Bytecode("1")) を使って例を再現します。LOAD_SMALL_INT の経路と _get_const_info の動作を確認します。完了の条件は、その Instruction に期待される空でない argrepr があること、およびリンクされた gh-140258 の作業に照らして動作が確認されていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100