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
()
| 81 | |
| 82 | |
| 83 | def _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 | |
| 100 | def _windowsconsoleio_workaround(stream: TextIO) -> None: |
no outgoing calls
no test coverage detected