Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fabioz opened this issue May 26, 2022 · 1 comment
Labels
docs Documentation in the Doc dir

Comments

@fabioz
Copy link
Contributor

fabioz commented May 26, 2022

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...).

@fabioz fabioz added the docs Documentation in the Doc dir label May 26, 2022
Christopher-Chianelli added a commit to Christopher-Chianelli/cpython that referenced this issue Nov 7, 2022
In Python 3.11 and above, the qualified name is no longer
in the consumed stack for MAKE_FUNCTION.
@Christopher-Chianelli
Copy link
Contributor

#93189 appears to be a fix for this doc issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants