8000 Pack everything into END_THROW · python/cpython@f4cc398 · GitHub
[go: up one dir, main page]

Skip to content

Commit f4cc398

Browse files
committed
Pack everything into END_THROW
1 parent 5348cbe commit f4cc398

File tree

12 files changed

+135
-139
lines changed

12 files changed

+135
-139
lines changed

Doc/library/dis.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,17 @@ the original TOS1.
567567
.. versionchanged:: 3.11
568568
Exception representation on the stack now consist of one, not three, items.
569569

570+
571+
.. opcode:: END_THROW
572+
573+
Handles an exception raised during a :meth:`~generator.throw` or
574+
:meth:`~generator.close` call through the current frame. If TOS is an
575+
instance of :exc:`StopIteration`, pop three values from the stack and push
576+
its ``value`` member. Otherwise, re-raise TOS.
577+
578+
.. versionadded:: 3.12
579+
580+
570581
.. opcode:: BEFORE_ASYNC_WITH
571582

572583
Resolves ``__aenter__`` and ``__aexit__`` from the object on top of the
@@ -709,14 +720,12 @@ iterations of the loop.
709720
Exception representation on the stack now consist of one, not three, items.
710721

711722

712-
.. opcode:: LOAD_EXCEPTION_TYPE (type)
713-
714-
Pushes an exception type onto the stack, depending on the value of *type*:
723+
.. opcode:: LOAD_ASSERTION_ERROR
715724

716-
* ``0``: :exc:`AssertionError`
717-
* ``1``: :exc:`StopIteration`
725+
Pushes :exc:`AssertionError` onto the stack. Used by the :keyword:`assert`
726+
statement.
718727

719-
.. versionadded:: 3.12
728+
.. versionadded:: 3.9
720729

721730

722731
.. opcode:: LOAD_BUILD_CLASS

Include/internal/pycore_opcode.h

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/opcode.h

Lines changed: 43 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/dis.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
JUMP_BACKWARD = opmap['JUMP_BACKWARD']
4040
FOR_ITER = opmap['FOR_ITER']
4141
LOAD_ATTR = opmap['LOAD_ATTR']
42-
LOAD_EXCEPTION_TYPE = opmap['LOAD_EXCEPTION_TYPE']
4342

4443
CACHE = opmap["CACHE"]
4544

@@ -498,8 +497,6 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
498497
if arg & (1<<i))
499498
elif deop == BINARY_OP:
500499
_, argrepr = _nb_ops[arg]
501-
elif deop == LOAD_EXCEPTION_TYPE:
502-
argrepr = "StopIteration" if arg else "AssertionError"
503500
yield Instruction(_all_opname[op], op,
504501
arg, argval, argrepr,
505502
offset, starts_line, is_jump_target, positions)

Lib/importlib/_bootstrap_external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def _write_atomic(path, data, mode=0o666):
411411
# Python 3.12a1 3505 (Specialization/Cache for FOR_ITER)
412412
# Python 3.12a1 3506 (Add BINARY_SLICE and STORE_SLICE instructions)
413413
# Python 3.12a1 3507 (Set lineno of module's RESUME to 0)
414-
# Python 3.12a1 3508 (Replace LOAD_ASSERTION_ERROR with LOAD_EXCEPTION_TYPE)
414+
# Python 3.12a1 3508 (Add END_THROW)
415415

416416
# Python 3.13 will start with 3550
417417

Lib/opcode.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def pseudo_op(name, op, real_ops):
104104
def_op('BEFORE_ASYNC_WITH', 52)
105105
def_op('BEFORE_WITH', 53)
106106
def_op('END_ASYNC_FOR', 54)
107+
def_op('END_THROW', 55)
107108

108109
def_op('STORE_SUBSCR', 60)
109110
def_op('DELETE_SUBSCR', 61)
@@ -113,6 +114,7 @@ def pseudo_op(name, op, real_ops):
113114
def_op('PRINT_EXPR', 70)
114115
def_op('LOAD_BUILD_CLASS', 71)
115116

117+
def_op('LOAD_ASSERTION_ERROR', 74)
116118
def_op('RETURN_GENERATOR', 75)
117119

118120
def_op('LIST_TO_TUPLE', 82)
@@ -186,7 +188,7 @@ def pseudo_op(name, op, real_ops):
186188
def_op('DELETE_DEREF', 139)
187189
hasfree.append(139)
188190
jrel_op('JUMP_BACKWARD', 140) # Number of words to skip (backwards)
189-
def_op('LOAD_EXCEPTION_TYPE', 141)
191+
190192
def_op('CALL_FUNCTION_EX', 142) # Flags
191193

192194
def_op('EXTENDED_ARG', 144)

0 commit comments

Comments
 (0)
0