From 2928b9a4b17c7ccb49a72ee1f1e39b734803ae7e Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Thu, 19 Jun 2014 14:23:08 +0100 Subject: [PATCH] Fix Singular pexpect timeouts on some platforms This patch calls tcsetattr later in an attempt to work around a bug on OSX Maverics and ancient Linux kernels. --- src/sage/interfaces/expect.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py index a4ddc514cad..4e47d545ecd 100644 --- a/src/sage/interfaces/expect.py +++ b/src/sage/interfaces/expect.py @@ -437,8 +437,6 @@ def _start(self, alt_message=None, block_during_init=True): os.chdir(current_path) self._expect.timeout = self.__max_startup_time - if not self._terminal_echo: - self._expect.setecho(0) #self._expect.setmaxread(self.__maxread) self._expect.maxread = self.__maxread @@ -451,6 +449,14 @@ def _start(self, alt_message=None, block_during_init=True): failed_to_start.append(self.name()) raise RuntimeError("Unable to start %s"%self.name()) self._expect.timeout = None + + # Calling tcsetattr earlier exposes bugs in various pty + # implementations, see :trac:`16474`. Since we haven't + # **written** anything so far it is safe to wait with + # switching echo off until now. + if not self._terminal_echo: + self._expect.setecho(0) + with gc_disabled(): if block_during_init: for X in self.__init_code: