You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sysconfig imports pprint which imports the world #106789
sysconfig imports pprint in order to print the config dict to a file. But this dict contains only strings and ints, so pprint is overkill.
The problem with importing pprint is that it imports dataclasses, which imports inspect, which imports dis which imports opcode which tries to import _opcode which does not exist in early stages of the build when sysconfig is used. So opcode imports _opcode in a try-except and ignores import errors. Since sysconfig doesn't need anything from _opcode, the partially constructed opcode module suffices. But this is flaky and hard to reason about (it works because it works). It would be better if sysconfig didn't import so much.
Honestly I think that dataclasses shouldn't import inspect, and inspect shouldn't import dis. But if this is the easiest way to fix the issue at hand, let's do it.
Regardless of other possible solutions, I think removing the sysconfig dependency on pprint is a valuable contribution on its own, so I am happy with it being merged.
Activity
pythongh-106789: avoid importing pprint from sysconfig
gvanrossum commentedon Jul 15, 2023
Honestly I think that dataclasses shouldn't import inspect, and inspect shouldn't import dis. But if this is the easiest way to fix the issue at hand, let's do it.
iritkatriel commentedon Jul 15, 2023
I'll look into that. Let's hold off merging this.
FFY00 commentedon Jul 15, 2023
Regardless of other possible solutions, I think removing the
sysconfigdependency onpprintis a valuable contribution on its own, so I am happy with it being merged.gh-106789: avoid importing pprint from sysconfig (#106790)