Permalink
Browse files

Override input(), not raw_input(), for Qt console in Python 3.

  • Loading branch information...
1 parent a88bf20 commit 786b191eefb8a6a2ab6547b8d86bad856a62367b @takluyver committed Aug 21, 2011
Showing with 10 additions and 2 deletions.
  1. +5 −1 IPython/zmq/ipkernel.py
  2. +5 −1 IPython/zmq/pykernel.py
View
@@ -33,6 +33,7 @@
InteractiveShellApp, shell_flags, shell_aliases
)
from IPython.utils import io
+from IPython.utils import py3compat
from IPython.utils.jsonutil import json_clean
from IPython.lib import pylabtools
from IPython.utils.traitlets import (
@@ -219,7 +220,10 @@ def execute_request(self, ident, parent):
# Replace raw_input. Note that is not sufficient to replace
# raw_input in the user namespace.
raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
- __builtin__.raw_input = raw_input
+ if py3compat.PY3:
+ __builtin__.input = raw_input
+ else:
+ __builtin__.raw_input = raw_input
# Set the parent message of the display hook and out streams.
shell.displayhook.set_parent(parent)
View
@@ -25,6 +25,7 @@
import zmq
# Local imports.
+from IPython.utils import py3compat
from IPython.utils.traitlets import HasTraits, Instance, Dict, Float
from completer import KernelCompleter
from entry_point import base_launch_kernel
@@ -116,7 +117,10 @@ def execute_request(self, ident, parent):
# Replace raw_input. Note that is not sufficient to replace
# raw_input in the user namespace.
raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
- __builtin__.raw_input = raw_input
+ if py3compat.PY3:
+ __builtin__.input = raw_input
+ else:
+ __builtin__.raw_input = raw_input
# Set the parent message of the display hook and out streams.
sys.displayhook.set_parent(parent)

0 comments on commit 786b191

Please sign in to comment.