[master 1/2] Only import readline if readline is necessary.

dashea installerbot-noreply at redhat.com
Thu Jul 16 15:05:38 UTC 2015


From: David Shea <dshea at redhat.com>

Weird things can happen when attempting to use readline when not
connected to a tty. Sometimes strange escape characters will appear, or
sometimes python will attempt to manipulate settings that do not exist,
or sometimes libedit will crash the party and break all your glassware.
It is all very mysterious and crash-prone.
---
 dracut/driver_updates.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dracut/driver_updates.py b/dracut/driver_updates.py
index e50eae9..f60480e 100755
--- a/dracut/driver_updates.py
+++ b/dracut/driver_updates.py
@@ -71,7 +71,12 @@
 import os
 import subprocess
 import fnmatch
-import readline # pylint:disable=unused-import
+
+# Import readline so raw_input gets readline features, like history, and
+# backspace working right. Do not import readline if not connected to a tty
+# because it breaks sometimes.
+if os.isatty(0):
+    import readline # pylint:disable=unused-import
 
 from contextlib import contextmanager
 from logging.handlers import SysLogHandler


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/c933b7c162d55e56190c0926b2e04d1c9befa57b


More information about the anaconda-patches mailing list