Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop readline workaround introduced in #1281 #8848

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/8733.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Drop a workaround for `pyreadline <https://github.com/pyreadline/pyreadline>`__ that made it work with ``--pdb``.

The workaround was introduced in `#1281 <https://github.com/pytest-dev/pytest/pull/1281>`__ in 2015, however since then
`pyreadline seems to have gone unmaintained <https://github.com/pyreadline/pyreadline/issues/58>`__, is `generating
warnings <https://github.com/pytest-dev/pytest/issues/8847>`__, and will stop working on Python 3.10.
25 changes: 0 additions & 25 deletions src/_pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,6 @@ def _colorama_workaround() -> None:
pass


def _readline_workaround() -> None:
"""Ensure readline is imported so that it attaches to the correct stdio
handles on Windows.

Pdb uses readline support where available--when not running from the Python
prompt, the readline module is not imported until running the pdb REPL. If
running pytest with the --pdb option this means the readline module is not
imported until after I/O capture has been started.

This is a problem for pyreadline, which is often used to implement readline
support on Windows, as it does not attach to the correct handles for stdout
and/or stdin if they have been redirected by the FDCapture mechanism. This
workaround ensures that readline is imported before I/O capture is setup so
that it can attach to the actual stdin/out for the console.

See https://github.com/pytest-dev/pytest/pull/1281.
"""
if sys.platform.startswith("win32"):
try:
import readline # noqa: F401
except ImportError:
pass


def _py36_windowsconsoleio_workaround(stream: TextIO) -> None:
"""Workaround for Windows Unicode console handling on Python>=3.6.

Expand Down Expand Up @@ -154,7 +130,6 @@ def pytest_load_initial_conftests(early_config: Config):
if ns.capture == "fd":
_py36_windowsconsoleio_workaround(sys.stdout)
_colorama_workaround()
_readline_workaround()
pluginmanager = early_config.pluginmanager
capman = CaptureManager(ns.capture)
pluginmanager.register(capman, "capturemanager")
Expand Down