Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sysconfig imports pprint which imports the world #106789

Closed
@iritkatriel

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

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