python / python/cpython

`dis.dis` on empty classes does nothing

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

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

stdlib type-feature
主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

説明

Bug report

Expected behavior

dis.dis on an empty class should output a message along the lines of "Nothing to disassemble", or possibly raise an exception in that regard

Actual behavior

dis.dis produces no output when passed a class with no __dict__ members.

Repro case

Test code pasteable in interactive session:

if 1:
 import sys
 from dis import dis
 class Empty: pass
 print('Python', sys.version)
 dis(Empty)

Output:
My local machine:

Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]

Tutorialspoint:

Python 3.8.6 (default, Jan 29 2021, 17:38:16) 
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

JDoodle:

Python 3.9.9 (main, Nov 20 2021, 21:30:06) 
[GCC 11.1.0]

Pyodide:

Python 3.10.2 (main, Aug  9 2022, 13:42:49) [Clang 15.0.0 (https://github.com/llvm/llvm-project 7effcbda49ba32991b8955821b8f

Your environment

  • CPython versions tested on: See output above
  • Operating system and architecture: See output above

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

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

はじめの一歩

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

調査の方向性

まず、提供された空のクラスの例を使い、dis.dis エントリーポイントを通じて報告された動作を再現します。dis.dis が dict メンバーを持たないクラスをどのように処理するかを追跡し、そのケースに対してユーザーに表示されるメッセージまたは例外を追加してから、空のクラスの例で今度は出力が何も生成されなくならないことを確認します。

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

評価

技術スタック
python
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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