mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-106789: avoid importing pprint from sysconfig (#106790)
This commit is contained in:
parent
7aa89e505d
commit
5ecedbd266
3 changed files with 12 additions and 19 deletions
|
@ -6,26 +6,14 @@ operate on bytecodes (e.g. peephole optimizers).
|
||||||
|
|
||||||
__all__ = ["cmp_op", "hasarg", "hasconst", "hasname", "hasjrel", "hasjabs",
|
__all__ = ["cmp_op", "hasarg", "hasconst", "hasname", "hasjrel", "hasjabs",
|
||||||
"haslocal", "hascompare", "hasfree", "hasexc", "opname", "opmap",
|
"haslocal", "hascompare", "hasfree", "hasexc", "opname", "opmap",
|
||||||
"HAVE_ARGUMENT", "EXTENDED_ARG"]
|
"stack_effect", "HAVE_ARGUMENT", "EXTENDED_ARG"]
|
||||||
|
|
||||||
# It's a chicken-and-egg I'm afraid:
|
from _opcode import stack_effect
|
||||||
# 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:
|
import sys
|
||||||
from _opcode import stack_effect
|
# The build uses older versions of Python which do not have _opcode_metadata
|
||||||
__all__.append('stack_effect')
|
if sys.version_info[:2] >= (3, 13):
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# _opcode_metadata may not be ready during early stages of the build
|
|
||||||
try:
|
|
||||||
from _opcode_metadata import _specializations, _specialized_instructions
|
from _opcode_metadata import _specializations, _specialized_instructions
|
||||||
except ModuleNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
cmp_op = ('<', '<=', '==', '!=', '>', '>=')
|
cmp_op = ('<', '<=', '==', '!=', '>', '>=')
|
||||||
|
|
||||||
|
|
|
@ -465,10 +465,14 @@ def _get_sysconfigdata_name():
|
||||||
f'_sysconfigdata_{sys.abiflags}_{sys.platform}_{multiarch}',
|
f'_sysconfigdata_{sys.abiflags}_{sys.platform}_{multiarch}',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _print_config_dict(d, stream):
|
||||||
|
print ("{", file=stream)
|
||||||
|
for k, v in sorted(d.items()):
|
||||||
|
print(f" {k!r}: {v!r},", file=stream)
|
||||||
|
print ("}", file=stream)
|
||||||
|
|
||||||
def _generate_posix_vars():
|
def _generate_posix_vars():
|
||||||
"""Generate the Python module containing build-time variables."""
|
"""Generate the Python module containing build-time variables."""
|
||||||
import pprint
|
|
||||||
vars = {}
|
vars = {}
|
||||||
# load the installed Makefile:
|
# load the installed Makefile:
|
||||||
makefile = get_makefile_filename()
|
makefile = get_makefile_filename()
|
||||||
|
@ -523,7 +527,7 @@ def _generate_posix_vars():
|
||||||
f.write('# system configuration generated and used by'
|
f.write('# system configuration generated and used by'
|
||||||
' the sysconfig module\n')
|
' the sysconfig module\n')
|
||||||
f.write('build_time_vars = ')
|
f.write('build_time_vars = ')
|
||||||
pprint.pprint(vars, stream=f)
|
_print_config_dict(vars, stream=f)
|
||||||
|
|
||||||
# Create file used for sys.path fixup -- see Modules/getpath.c
|
# Create file used for sys.path fixup -- see Modules/getpath.c
|
||||||
with open('pybuilddir.txt', 'w', encoding='utf8') as f:
|
with open('pybuilddir.txt', 'w', encoding='utf8') as f:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Remove import of :mod:``pprint`` from :mod:``sysconfig``.
|
Loading…
Add table
Add a link
Reference in a new issue