python / python/cpython

`dis.dis` on empty classes does nothing

Open
#95,940 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior through the dis.dis entry point with the provided Empty class example. Trace how dis.dis handles a class with no dict members, then add a user-visible message or exception for that case and verify that the empty-class example no longer produces no output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.