MCPcopy
hub / github.com/pytest-dev/pytest / _readline_workaround

Function _readline_workaround

src/_pytest/capture.py:83–97  ·  view source on GitHub ↗

Ensure readline is imported early so it attaches to the correct stdio handles. This isn't a problem with the default GNU readline implementation, but in some configurations, Python uses libedit instead (on macOS, and for prebuilt binaries such as used by uv). In theory this is only

()

Source from the content-addressed store, hash-verified

81
82
83def _readline_workaround() -> None:
84 """Ensure readline is imported early so it attaches to the correct stdio handles.
85
86 This isn't a problem with the default GNU readline implementation, but in
87 some configurations, Python uses libedit instead (on macOS, and for prebuilt
88 binaries such as used by uv).
89
90 In theory this is only needed if readline.backend == "libedit", but the
91 workaround consists of importing readline here, so we already worked around
92 the issue by the time we could check if we need to.
93 """
94 try:
95 import readline # noqa: F401
96 except ImportError:
97 pass
98
99
100def _windowsconsoleio_workaround(stream: TextIO) -> None:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected