mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321)
The PEP 649 implementation will require a way to load NotImplementedError from the bytecode. @markshannon suggested implementing this by converting LOAD_ASSERTION_ERROR into a more general mechanism for loading constants. This PR adds this new opcode. I will work on the rest of the implementation of the PEP separately. Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
parent
506b1a3ff6
commit
98e855fcc1
22 changed files with 337 additions and 288 deletions
|
|
@ -3974,7 +3974,7 @@ compiler_assert(struct compiler *c, stmt_ty s)
|
|||
}
|
||||
NEW_JUMP_TARGET_LABEL(c, end);
|
||||
RETURN_IF_ERROR(compiler_jump_if(c, LOC(s), s->v.Assert.test, end, 1));
|
||||
ADDOP(c, LOC(s), LOAD_ASSERTION_ERROR);
|
||||
ADDOP_I(c, LOC(s), LOAD_COMMON_CONSTANT, CONSTANT_ASSERTIONERROR);
|
||||
if (s->v.Assert.msg) {
|
||||
VISIT(c, expr, s->v.Assert.msg);
|
||||
ADDOP_I(c, LOC(s), CALL, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue