[Python-checkins] cpython: Issue #26870: Avoid using kqueue() with pseudo-terminals
martin.panter
python-checkins at python.org
Sun May 15 09:22:56 EDT 2016
https://hg.python.org/cpython/rev/816e1fe72c1e
changeset: 101345:816e1fe72c1e
user: Martin Panter <vadmium+py at gmail.com>
date: Sun May 15 13:21:25 2016 +0000
summary:
Issue #26870: Avoid using kqueue() with pseudo-terminals
Also force terminate the child process in case it hangs for any reason.
files:
Lib/test/test_readline.py | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py
--- a/Lib/test/test_readline.py
+++ b/Lib/test/test_readline.py
@@ -9,7 +9,7 @@
import sys
import tempfile
import unittest
-from test.support import import_module, unlink, get_original_stdout
+from test.support import import_module, unlink
from test.support.script_helper import assert_python_ok
# Skip tests if there is no readline module
@@ -126,30 +126,30 @@
os.close(slave)
with ExitStack() as cleanup:
cleanup.enter_context(proc)
+ cleanup.callback(proc.terminate)
cleanup.callback(os.close, master)
- sel = cleanup.enter_context(selectors.DefaultSelector())
+ # Avoid using DefaultSelector, because it may choose a kqueue()
+ # implementation, which does not work with pseudo-terminals on OS X
+ # < 10.9 (Issue 20365) and Open BSD (Issue 20667).
+ sel = getattr(selectors, "PollSelector", selectors.DefaultSelector)()
+ cleanup.enter_context(sel)
sel.register(master, selectors.EVENT_READ | selectors.EVENT_WRITE)
os.set_blocking(master, False)
while True:
- get_original_stdout().write(f"test_readline: select()\n")
for [_, events] in sel.select():
if events & selectors.EVENT_READ:
try:
- get_original_stdout().write(f"test_readline: read()\n")
chunk = os.read(master, 0x10000)
except OSError as err:
# Linux raises EIO when the slave is closed
if err.errno != EIO:
raise
chunk = b""
- get_original_stdout().write(f"test_readline: read {chunk!r}\n")
if not chunk:
return output
output.extend(chunk)
if events & selectors.EVENT_WRITE:
- get_original_stdout().write(f"test_readline: write()\n")
input = input[os.write(master, input):]
- get_original_stdout().write(f"test_readline: remaining input = {input!r}\n")
if not input:
sel.modify(master, selectors.EVENT_READ)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list