python / python/cpython

`dis.dis` on empty classes does nothing

未關閉
#95,940 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先透過提供的 Empty 類別範例,從 dis.dis 入口點重現所回報的行為。追蹤 dis.dis 如何處理沒有 dict 成員的類別,然後針對該情況新增一則使用者可見的訊息或例外,並驗證空類別範例不再出現無輸出的情況。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
devtools
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。