Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-106789: avoid importing pprint from sysconfig #106790

Merged
merged 6 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 4 additions & 18 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,10 @@
"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:
from _opcode_metadata import _specializations, _specialized_instructions
except ModuleNotFoundError:
pass
from _opcode import stack_effect
__all__.append('stack_effect')

from _opcode_metadata import _specializations, _specialized_instructions

cmp_op = ('<', '<=', '==', '!=', '>', '>=')

Expand Down
8 changes: 6 additions & 2 deletions Lib/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,14 @@ def _get_sysconfigdata_name():
f'_sysconfigdata_{sys.abiflags}_{sys.platform}_{multiarch}',
)

def _print_config_dict(d, stream):
print (" {", file=stream)
iritkatriel marked this conversation as resolved.
Show resolved Hide resolved
for k, v in sorted(d.items()):
print(f" {k!r}: {v!r},", file=stream)
print ("}", file=stream)

def _generate_posix_vars():
"""Generate the Python module containing build-time variables."""
import pprint
vars = {}
# load the installed Makefile:
makefile = get_makefile_filename()
Expand Down Expand Up @@ -523,7 +527,7 @@ def _generate_posix_vars():
f.write('# system configuration generated and used by'
' the sysconfig module\n')
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
with open('pybuilddir.txt', 'w', encoding='utf8') as f:
Expand Down