Skip to content

Commit a94461d

Browse files
authored
bpo-46202: Remove opcode POP_EXCEPT_AND_RERAISE (GH-30302)
* bpo-46202: remove opcode POP_EXCEPT_AND_RERAISE * do not assume that an exception group is truthy
1 parent a09062c commit a94461d

File tree

11 files changed

+138
-146
lines changed

11 files changed

+138
-146
lines changed

Doc/library/dis.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,16 +603,6 @@ iterations of the loop.
603603
The ``__exit__`` function is in position 4 of the stack rather than 7.
604604
Exception representation on the stack now consist of one, not three, items.
605605

606-
.. opcode:: POP_EXCEPT_AND_RERAISE
607-
608-
Pops the exception currently on top of the stack. Pops the integer value on top
609-
of the stack and sets the ``f_lasti`` attribute of the frame with that value.
610-
Then pops the next exception from the stack uses it to restore the current exception.
611-
Finally it re-raises the originally popped exception.
612-
Used in exception handler cleanup.
613-
614-
.. versionadded:: 3.11
615-
616606

617607
.. opcode:: LOAD_ASSERTION_ERROR
618608

Include/opcode.h

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

Lib/importlib/_bootstrap_external.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def _write_atomic(path, data, mode=0o666):
376376
# Python 3.11a4 3468 (Add SEND opcode)
377377
# Python 3.11a4 3469 (bpo-45711: remove type, traceback from exc_info)
378378
# Python 3.11a4 3470 (bpo-46221: PREP_RERAISE_STAR no longer pushes lasti)
379+
# Python 3.11a4 3471 (bpo-46202: remove pop POP_EXCEPT_AND_RERAISE)
379380

380381
#
381382
# MAGIC must change whenever the bytecode emitted by the compiler may no
@@ -385,7 +386,7 @@ def _write_atomic(path, data, mode=0o666):
385386
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
386387
# in PC/launcher.c must also be updated.
387388

388-
MAGIC_NUMBER = (3470).to_bytes(2, 'little') + b'\r\n'
389+
MAGIC_NUMBER = (3471).to_bytes(2, 'little') + b'\r\n'
389390
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
390391

391392
_PYCACHE = '__pycache__'

Lib/opcode.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def jabs_op(name, op):
7777

7878
def_op('PUSH_EXC_INFO', 35)
7979

80-
def_op('POP_EXCEPT_AND_RERAISE', 37)
81-
8280
def_op('WITH_EXCEPT_START', 49)
8381
def_op('GET_AITER', 50)
8482
def_op('GET_ANEXT', 51)

Lib/test/test_code.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ def test_co_positions_artificial_instructions(self):
383383
("STORE_NAME", "e"), # XX: we know the location for this
384384
("DELETE_NAME", "e"),
385385
("RERAISE", 1),
386-
("POP_EXCEPT_AND_RERAISE", None)
386+
("COPY", 3),
387+
("POP_EXCEPT", None),
388+
("RERAISE", 1)
387389
]
388390
)
389391

0 commit comments

Comments
 (0)