summaryrefslogtreecommitdiffstats
path: root/Lib/opcode.py
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-07-17 09:28:33 (GMT)
committerGitHub <noreply@github.com>2023-07-17 09:28:33 (GMT)
commit5ecedbd26692b9fbdd7aad81b991869bf650f929 (patch)
tree443aec6660dfe3df13bb39cfddc6d24bd20438bc /Lib/opcode.py
parent7aa89e505d893cd5e6f33b84d66e5fa769089931 (diff)
downloadcpython-5ecedbd26692b9fbdd7aad81b991869bf650f929.zip
cpython-5ecedbd26692b9fbdd7aad81b991869bf650f929.tar.gz
cpython-5ecedbd26692b9fbdd7aad81b991869bf650f929.tar.bz2
gh-106789: avoid importing pprint from sysconfig (#106790)
Diffstat (limited to 'Lib/opcode.py')
-rw-r--r--Lib/opcode.py26
1 files changed, 7 insertions, 19 deletions
diff --git a/Lib/opcode.py b/Lib/opcode.py
index bc88505..1b36300 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -6,26 +6,14 @@ operate on bytecodes (e.g. peephole optimizers).
__all__ = ["cmp_op", "hasarg", "hasconst", "hasname", "hasjrel", "hasjabs",
"haslocal", "hascompare", "hasfree", "hasexc", "opname", "opmap",
- "HAVE_ARGUMENT", "EXTENDED_ARG"]
-
-# It's a chicken-and-egg I'm afraid:
-# We're imported before _opcode's made.
-# With exception unheeded
-# (stack_effect is not needed)
-# Both our chickens and eggs are allayed.
-# --Larry Hastings, 2013/11/23
-
-try:
- from _opcode import stack_effect
- __all__.append('stack_effect')
-except ImportError:
- pass
-
-# _opcode_metadata may not be ready during early stages of the build
-try:
+ "stack_effect", "HAVE_ARGUMENT", "EXTENDED_ARG"]
+
+from _opcode import stack_effect
+
+import sys
+# The build uses older versions of Python which do not have _opcode_metadata
+if sys.version_info[:2] >= (3, 13):
from _opcode_metadata import _specializations, _specialized_instructions
-except ModuleNotFoundError:
- pass
cmp_op = ('<', '<=', '==', '!=', '>', '>=')