Skip to content

The documentation of MAKE_FUNCTION in Python 3.11 does not reflect the actual usage #93270

@fabioz

Description

@fabioz

Documentation

The documentation for 3.11 (https://docs.python.org/3.11/library/dis.html#opcode-MAKE_FUNCTION) related to MAKE_FUNCTION seems to be the same for Python 3.10, which would expect 2 elements to be removed from the stack, yet, it seems that only 1 element is removed from the stack (it appears that the qualifier is no longer there).

i.e.:
Given:

import dis

def func():
    def check():
        pass

dis.dis(func)

The output I have in 3.11 is:

  4           0 RESUME                   0

  5           2 LOAD_CONST               1 (<code object check at 0x000001F555E3EAD0, file "W:\pydev.debugger\check\snippet6.py", line 5>)
              4 MAKE_FUNCTION            0
              6 STORE_FAST               0 (check)
              8 LOAD_CONST               0 (None)
             10 RETURN_VALUE

Disassembly of <code object check at 0x000001F555E3EAD0, file "W:\pydev.debugger\check\snippet6.py", line 5>:
  5           0 RESUME                   0

  6           2 LOAD_CONST               0 (None)
              4 RETURN_VALUE

and in 3.10 it is:

  5           0 LOAD_CONST               1 (<code object check at 0x000001F384D5D370, file "W:\pydev.debugger\check\snippet6.py", line 5>)
              2 LOAD_CONST               2 ('func.<locals>.check')
              4 MAKE_FUNCTION            0
              6 STORE_FAST               0 (check)
              8 LOAD_CONST               0 (None)
             10 RETURN_VALUE

Disassembly of <code object check at 0x000001F384D5D370, file "W:\pydev.debugger\check\snippet6.py", line 5>:
  6           0 LOAD_CONST               0 (None)
              2 RETURN_VALUE

The __qualname__ still seems to be set in the function (but that's probably happening through some other way now...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy