Skip to content

Commit 70d3d0f

Browse files
authored
Drop readline workaround introduced in #1281 (#8848)
Fix #8733 Closes #8847
1 parent b3ed595 commit 70d3d0f

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

changelog/8733.breaking.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Drop a workaround for `pyreadline <https://github.com/pyreadline/pyreadline>`__ that made it work with ``--pdb``.
2+
3+
The workaround was introduced in `#1281 <https://github.com/pytest-dev/pytest/pull/1281>`__ in 2015, however since then
4+
`pyreadline seems to have gone unmaintained <https://github.com/pyreadline/pyreadline/issues/58>`__, is `generating
5+
warnings <https://github.com/pytest-dev/pytest/issues/8847>`__, and will stop working on Python 3.10.

src/_pytest/capture.py

-25
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,6 @@ def _colorama_workaround() -> None:
6868
pass
6969

7070

71-
def _readline_workaround() -> None:
72-
"""Ensure readline is imported so that it attaches to the correct stdio
73-
handles on Windows.
74-
75-
Pdb uses readline support where available--when not running from the Python
76-
prompt, the readline module is not imported until running the pdb REPL. If
77-
running pytest with the --pdb option this means the readline module is not
78-
imported until after I/O capture has been started.
79-
80-
This is a problem for pyreadline, which is often used to implement readline
81-
support on Windows, as it does not attach to the correct handles for stdout
82-
and/or stdin if they have been redirected by the FDCapture mechanism. This
83-
workaround ensures that readline is imported before I/O capture is setup so
84-
that it can attach to the actual stdin/out for the console.
85-
86-
See https://github.com/pytest-dev/pytest/pull/1281.
87-
"""
88-
if sys.platform.startswith("win32"):
89-
try:
90-
import readline # noqa: F401
91-
except ImportError:
92-
pass
93-
94-
9571
def _py36_windowsconsoleio_workaround(stream: TextIO) -> None:
9672
"""Workaround for Windows Unicode console handling on Python>=3.6.
9773
@@ -154,7 +130,6 @@ def pytest_load_initial_conftests(early_config: Config):
154130
if ns.capture == "fd":
155131
_py36_windowsconsoleio_workaround(sys.stdout)
156132
_colorama_workaround()
157-
_readline_workaround()
158133
pluginmanager = early_config.pluginmanager
159134
capman = CaptureManager(ns.capture)
160135
pluginmanager.register(capman, "capturemanager")

0 commit comments

Comments
 (0)