summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2024-05-22 00:46:39 (GMT)
committerGitHub <noreply@github.com>2024-05-22 00:46:39 (GMT)
commit98e855fcc1f1d490c803565e84cb611b3f057e45 (patch)
tree53f19fb0244fa8c43e53534c31842adf5b65ebc2 /Lib/dis.py
parent506b1a3ff66a41c72d205c8e4cba574e439d8e76 (diff)
downloadcpython-98e855fcc1f1d490c803565e84cb611b3f057e45.zip
cpython-98e855fcc1f1d490c803565e84cb611b3f057e45.tar.gz
cpython-98e855fcc1f1d490c803565e84cb611b3f057e45.tar.bz2
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>
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 76934eb..f5bb797 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -11,6 +11,7 @@ from opcode import (
_cache_format,
_inline_cache_entries,
_nb_ops,
+ _common_constants,
_intrinsic_1_descs,
_intrinsic_2_descs,
_specializations,
@@ -44,6 +45,7 @@ LOAD_ATTR = opmap['LOAD_ATTR']
LOAD_SUPER_ATTR = opmap['LOAD_SUPER_ATTR']
CALL_INTRINSIC_1 = opmap['CALL_INTRINSIC_1']
CALL_INTRINSIC_2 = opmap['CALL_INTRINSIC_2']
+LOAD_COMMON_CONSTANT = opmap['LOAD_COMMON_CONSTANT']
LOAD_FAST_LOAD_FAST = opmap['LOAD_FAST_LOAD_FAST']
STORE_FAST_LOAD_FAST = opmap['STORE_FAST_LOAD_FAST']
STORE_FAST_STORE_FAST = opmap['STORE_FAST_STORE_FAST']
@@ -601,6 +603,12 @@ class ArgResolver:
argrepr = _intrinsic_1_descs[arg]
elif deop == CALL_INTRINSIC_2:
argrepr = _intrinsic_2_descs[arg]
+ elif deop == LOAD_COMMON_CONSTANT:
+ obj = _common_constants[arg]
+ if isinstance(obj, type):
+ argrepr = obj.__name__
+ else:
+ argrepr = repr(obj)
return argval, argrepr
def get_instructions(x, *, first_line=None, show_caches=None, adaptive=False):