diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-06-11 15:59:43 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-06-11 15:59:43 (GMT) |
commit | eec3d7137929611b98dd593cd2f122cd91b723b2 (patch) | |
tree | 42721419d4fe3f53961ecfd7c1dea3224188ae40 /Doc | |
parent | e8465f2b413174084fcc2dc4cd7a53122c62ce4b (diff) | |
download | cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.zip cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.tar.gz cpython-eec3d7137929611b98dd593cd2f122cd91b723b2.tar.bz2 |
#3021: Antoine Pitrou's Lexical exception handlers
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/dis.rst | 36 | ||||
-rw-r--r-- | Doc/library/inspect.rst | 11 | ||||
-rw-r--r-- | Doc/library/sys.rst | 4 | ||||
-rw-r--r-- | Doc/reference/datamodel.rst | 13 |
4 files changed, 27 insertions, 37 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! diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index a87651f..98ecbcb 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -94,17 +94,6 @@ attributes: | | f_code | code object being | | | | executed in this frame | +-----------+-----------------+---------------------------+ -| | f_exc_traceback | traceback if raised in | -| | | this frame, or ``None`` | -+-----------+-----------------+---------------------------+ -| | f_exc_type | exception type if raised | -| | | in this frame, or | -| | | ``None`` | -+-----------+-----------------+---------------------------+ -| | f_exc_value | exception value if raised | -| | | in this frame, or | -| | | ``None`` | -+-----------+-----------------+---------------------------+ | | f_globals | global namespace seen by | | | | this frame | +-----------+-----------------+---------------------------+ diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index b69de3f..42c36a6 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -136,8 +136,8 @@ always available. frame is not handling an exception, the information is taken from the calling stack frame, or its caller, and so on until a stack frame is found that is handling an exception. Here, "handling an exception" is defined as "executing - or having executed an except clause." For any stack frame, only information - about the most recently handled exception is accessible. + an except clause." For any stack frame, only information about the exception + being currently handled is accessible. .. index:: object: traceback diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 6562b00..4e24df7 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -875,19 +875,14 @@ Internal types .. index:: single: f_trace (frame attribute) - single: f_exc_type (frame attribute) - single: f_exc_value (frame attribute) - single: f_exc_traceback (frame attribute) single: f_lineno (frame attribute) Special writable attributes: :attr:`f_trace`, if not ``None``, is a function called at the start of each source code line (this is used by the debugger); - :attr:`f_exc_type`, :attr:`f_exc_value`, :attr:`f_exc_traceback` represent the - last exception raised in the parent frame provided another exception was ever - raised in the current frame (in all other cases they are None); :attr:`f_lineno` - is the current line number of the frame --- writing to this from within a trace - function jumps to the given line (only for the bottom-most frame). A debugger - can implement a Jump command (aka Set Next Statement) by writing to f_lineno. + :attr:`f_lineno` is the current line number of the frame --- writing to this + from within a trace function jumps to the given line (only for the bottom-most + frame). A debugger can implement a Jump command (aka Set Next Statement) + by writing to f_lineno. Traceback objects .. index:: |