Skip to content

Commit

Permalink
BUG: Don't use readline in the ZMQShell.
Browse files Browse the repository at this point in the history
  • Loading branch information
epatters committed Sep 14, 2011
1 parent 2205dbc commit 14ae4c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
18 changes: 17 additions & 1 deletion IPython/core/interactiveshell.py
Expand Up @@ -108,6 +108,11 @@ def softspace(file, newvalue):

def no_op(*a, **kw): pass

class NoOpContext(object):
def __enter__(self): pass
def __exit__(self, type, value, traceback): pass
no_op_context = NoOpContext()

class SpaceInInput(Exception): pass

class Bunch: pass
Expand Down Expand Up @@ -242,6 +247,15 @@ class InteractiveShell(SingletonConfigurable, Magic):
default_value=get_default_colors(), config=True,
help="Set the color scheme (NoColor, Linux, or LightBG)."
)
colors_force = CBool(False, help=
"""
Force use of ANSI color codes, regardless of OS and readline
availability.
"""
# FIXME: This is essentially a hack to allow ZMQShell to show colors
# without readline on Win32. When the ZMQ formatting system is
# refactored, this should be removed.
)
debug = CBool(False, config=True)
deep_reload = CBool(False, config=True, help=
"""
Expand Down Expand Up @@ -1636,10 +1650,12 @@ def init_readline(self):
self.has_readline = False
self.readline = None
# Set a number of methods that depend on readline to be no-op
self.readline_no_record = no_op_context
self.set_readline_completer = no_op
self.set_custom_completer = no_op
self.set_completer_frame = no_op
warn('Readline services not available or not loaded.')
if self.readline_use:
warn('Readline services not available or not loaded.')
else:
self.has_readline = True
self.readline = readline
Expand Down
5 changes: 3 additions & 2 deletions IPython/core/magic.py
Expand Up @@ -2496,7 +2496,8 @@ def color_switch_err(name):

import IPython.utils.rlineimpl as readline

if not readline.have_readline and sys.platform == "win32":
if not shell.colors_force and \
not readline.have_readline and sys.platform == "win32":
msg = """\
Proper color support under MS Windows requires the pyreadline library.
You can find it at:
Expand All @@ -2510,7 +2511,7 @@ def color_switch_err(name):
warn(msg)

# readline option is 0
if not shell.has_readline:
if not shell.colors_force and not shell.has_readline:
new_scheme = 'NoColor'

# Set prompt colors
Expand Down
9 changes: 2 additions & 7 deletions IPython/zmq/zmqshell.py
Expand Up @@ -84,13 +84,8 @@ class ZMQInteractiveShell(InteractiveShell):
# Override the traitlet in the parent class, because there's no point using
# readline for the kernel. Can be removed when the readline code is moved
# to the terminal frontend.

# FIXME. This is disabled for now, even though it may cause problems under
# Windows, because it breaks %run in the Qt console. See gh-617 for more
# details. Re-enable once we've fully tested that %run works in the Qt
# console with syntax highlighting in tracebacks.
# readline_use = CBool(False)
# /FIXME
colors_force = CBool(True)
readline_use = CBool(False)

exiter = Instance(ZMQExitAutocall)
def _exiter_default(self):
Expand Down

0 comments on commit 14ae4c0

Please sign in to comment.