summaryrefslogtreecommitdiffstats
path: root/Doc/library/dis.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-06-11 15:59:43 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-06-11 15:59:43 (GMT)
commiteec3d7137929611b98dd593cd2f122cd91b723b2 (patch)
tree42721419d4fe3f53961ecfd7c1dea3224188ae40 /Doc/library/dis.rst
parente8465f2b413174084fcc2dc4cd7a53122c62ce4b (diff)
downloadcpython-eec3d7137929611b98dd593cd2f122cd91b723b2.zip
cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.tar.gz
cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.tar.bz2
#3021: Antoine Pitrou's Lexical exception handlers
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r--Doc/library/dis.rst36
1 files changed, 21 insertions, 15 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 125a80f..6b2de49 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -397,6 +397,14 @@ Miscellaneous opcodes.
denoting nested loops, try statements, and such.
+.. opcode:: POP_EXCEPT ()
+
+ Removes one block from the block stack. The popped block must be an exception
+ handler block, as implicitly created when entering an except handler.
+ In addition to popping extraneous values from the frame stack, the
+ last three popped values are used to restore the exception state.
+
+
.. opcode:: END_FINALLY ()
Terminates a :keyword:`finally` clause. The interpreter recalls whether the
@@ -412,24 +420,22 @@ Miscellaneous opcodes.
.. opcode:: WITH_CLEANUP ()
- Cleans up the stack when a :keyword:`with` statement block exits. On top of
- the stack are 1--3 values indicating how/why the finally clause was entered:
-
- * TOP = ``None``
- * (TOP, SECOND) = (``WHY_{RETURN,CONTINUE}``), retval
- * TOP = ``WHY_*``; no retval below it
- * (TOP, SECOND, THIRD) = exc_info()
+ Cleans up the stack when a :keyword:`with` statement block exits. TOS is
+ the context manager's :meth:`__exit__` bound method. Below TOS are 1--3
+ values indicating how/why the finally clause was entered:
- Under them is EXIT, the context manager's :meth:`__exit__` bound method.
+ * SECOND = ``None``
+ * (SECOND, THIRD) = (``WHY_{RETURN,CONTINUE}``), retval
+ * SECOND = ``WHY_*``; no retval below it
+ * (SECOND, THIRD, FOURTH) = exc_info()
- In the last case, ``EXIT(TOP, SECOND, THIRD)`` is called, otherwise
- ``EXIT(None, None, None)``.
+ In the last case, ``TOS(SECOND, THIRD, FOURTH)`` is called, otherwise
+ ``TOS(None, None, None)``. In addition, TOS is removed from the stack.
- EXIT is removed from the stack, leaving the values above it in the same
- order. In addition, if the stack represents an exception, *and* the function
- call returns a 'true' value, this information is "zapped", to prevent
- ``END_FINALLY`` from re-raising the exception. (But non-local gotos should
- still be resumed.)
+ If the stack represents an exception, *and* the function call returns
+ a 'true' value, this information is "zapped" and replaced with a single
+ ``WHY_SILENCED`` to prevent ``END_FINALLY`` from re-raising the exception.
+ (But non-local gotos will still be resumed.)
.. XXX explain the WHY stuff!