diff options
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r-- | Doc/library/dis.rst | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 8d4d956..341beb5 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -436,6 +436,18 @@ the stack so that it is available for further iterations of the loop. by ``CALL_FUNCTION`` to construct a class. +.. opcode:: SETUP_WITH (delta) + + This opcode performs several operations before a with block starts. First, + it loads :meth:`~object.__exit__` from the context manager and pushes it onto + the stack for later use by :opcode:`WITH_CLEANUP`. Then, + :meth:`~object.__enter__` is called, and a finally block pointing to *delta* + is pushed. Finally, the result of calling the enter method is pushed onto + the stack. The next opcode will either ignore it (:opcode:`POP_TOP`), or + store it in (a) variable(s) (:opcode:`STORE_FAST`, :opcode:`STORE_NAME`, or + :opcode:`UNPACK_SEQUENCE`). + + .. opcode:: WITH_CLEANUP () Cleans up the stack when a :keyword:`with` statement block exits. TOS is |