Skip to content

dis.dis on empty classes does nothing #95940

Open
@Kenny2github

Description

@Kenny2github

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions