From 518e991b4a6bd69e5e3ceb39c54e08b374355546 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 15 Jun 2023 17:28:53 -0700 Subject: [PATCH 1/2] gh-105678: document SET_FUNCTION_ATTRIBUTE --- Doc/library/dis.rst | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index c6f08affcbf2d0..ec5e60e8ffe325 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -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.12 + 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) From 0627d2e8a2f4cde3e1ff13bcda061717b8f293b0 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Fri, 16 Jun 2023 10:13:54 -0700 Subject: [PATCH 2/2] fix versionchanged version --- Doc/library/dis.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index ec5e60e8ffe325..1caf3c097e1dce 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1431,7 +1431,7 @@ iterations of the loop. .. versionchanged:: 3.11 Qualified name at ``STACK[-1]`` was removed. - .. versionchanged:: 3.12 + .. versionchanged:: 3.13 Extra function attributes on the stack, signaled by oparg flags, were removed. They now use :opcode:`SET_FUNCTION_ATTRIBUTE`.