Skip to content

gh-105678: document SET_FUNCTION_ATTRIBUTE #105843

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

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1421,23 +1421,34 @@ iterations of the loop.
.. versionadded:: 3.11


.. opcode:: MAKE_FUNCTION (flags)
.. opcode:: MAKE_FUNCTION

Pushes a new function object on the stack. From bottom to top, the consumed
stack must consist of values if the argument carries a specified flag value
Pushes a new function object on the stack built from the code object at ``STACK[1]``.

.. versionchanged:: 3.10
Flag value ``0x04`` is a tuple of strings instead of dictionary

.. versionchanged:: 3.11
Qualified name at ``STACK[-1]`` was removed.

.. versionchanged:: 3.13
Extra function attributes on the stack, signaled by oparg flags, were
removed. They now use :opcode:`SET_FUNCTION_ATTRIBUTE`.


.. opcode:: SET_FUNCTION_ATTRIBUTE (flag)

Sets an attribute on a function object. Expects the function at ``STACK[-1]``
and the attribute value to set at ``STACK[-2]``; consumes both and leaves the
function at ``STACK[-1]``. The flag determines which attribute to set:

* ``0x01`` a tuple of default values for positional-only and
positional-or-keyword parameters in positional order
* ``0x02`` a dictionary of keyword-only parameters' default values
* ``0x04`` a tuple of strings containing parameters' annotations
* ``0x08`` a tuple containing cells for free variables, making a closure
* the code associated with the function (at ``STACK[-1]``)

.. versionchanged:: 3.10
Flag value ``0x04`` is a tuple of strings instead of dictionary

.. versionchanged:: 3.11
Qualified name at ``STACK[-1]`` was removed.
.. versionadded:: 3.13


.. opcode:: BUILD_SLICE (argc)
Expand Down