Skip to content

sysconfig imports pprint which imports the world #106789

Closed

Description

@iritkatriel

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.

Linked PRs

Activity

  1. added a commit that references this issue on Jul 15, 2023
  2. gvanrossum commented on Jul 15, 2023

    @gvanrossum
    Member

    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.

  3. iritkatriel commented on Jul 15, 2023

    @iritkatriel
    MemberAuthor

    I'll look into that. Let's hold off merging this.

  4. FFY00 commented on Jul 15, 2023

    @FFY00
    Member

    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.

  5. added a commit that references this issue on Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions