@@ -397,6 +397,14 @@ Miscellaneous opcodes.
397397 denoting nested loops, try statements, and such.
398398
399399
400+ .. opcode :: POP_EXCEPT ()
401+
402+ Removes one block from the block stack. The popped block must be an exception
403+ handler block, as implicitly created when entering an except handler.
404+ In addition to popping extraneous values from the frame stack, the
405+ last three popped values are used to restore the exception state.
406+
407+
400408.. opcode :: END_FINALLY ()
401409
402410 Terminates a :keyword: `finally ` clause. The interpreter recalls whether the
@@ -412,24 +420,22 @@ Miscellaneous opcodes.
412420
413421.. opcode :: WITH_CLEANUP ()
414422
415- Cleans up the stack when a :keyword: `with ` statement block exits. On top of
416- the stack are 1--3 values indicating how/why the finally clause was entered:
417-
418- * TOP = ``None ``
419- * (TOP, SECOND) = (``WHY_{RETURN,CONTINUE} ``), retval
420- * TOP = ``WHY_* ``; no retval below it
421- * (TOP, SECOND, THIRD) = exc_info()
423+ Cleans up the stack when a :keyword: `with ` statement block exits. TOS is
424+ the context manager's :meth: `__exit__ ` bound method. Below TOS are 1--3
425+ values indicating how/why the finally clause was entered:
422426
423- Under them is EXIT, the context manager's :meth: `__exit__ ` bound method.
427+ * SECOND = ``None ``
428+ * (SECOND, THIRD) = (``WHY_{RETURN,CONTINUE} ``), retval
429+ * SECOND = ``WHY_* ``; no retval below it
430+ * (SECOND, THIRD, FOURTH) = exc_info()
424431
425- In the last case, ``EXIT(TOP, SECOND, THIRD) `` is called, otherwise
426- ``EXIT (None, None, None) ``.
432+ In the last case, ``TOS( SECOND, THIRD, FOURTH ) `` is called, otherwise
433+ ``TOS (None, None, None) ``. In addition, TOS is removed from the stack .
427434
428- EXIT is removed from the stack, leaving the values above it in the same
429- order. In addition, if the stack represents an exception, *and * the function
430- call returns a 'true' value, this information is "zapped", to prevent
431- ``END_FINALLY `` from re-raising the exception. (But non-local gotos should
432- still be resumed.)
435+ If the stack represents an exception, *and * the function call returns
436+ a 'true' value, this information is "zapped" and replaced with a single
437+ ``WHY_SILENCED `` to prevent ``END_FINALLY `` from re-raising the exception.
438+ (But non-local gotos will still be resumed.)
433439
434440 .. XXX explain the WHY stuff!
435441
0 commit comments