Permalink
Browse files

BUG: Solve 2to3 conversion error.

One of the methods in the inprocess kernel objects used
a local variable called `raw_input` that was mistakenly
converted to `input` during the 2to3 conversion.
  • Loading branch information...
1 parent 270e9a5 commit 36f98b608e5f7fb00a4bae11c230623cd969c286 @pberkes committed Dec 27, 2012
Showing with 11 additions and 8 deletions.
  1. +2 −2 IPython/inprocess/blockingkernelmanager.py
  2. +9 −6 IPython/zmq/ipkernel.py
@@ -74,10 +74,10 @@ def call_handlers(self, msg):
"""
msg_type = msg['header']['msg_type']
if msg_type == 'input_request':
- raw_input = self.manager.kernel.sys_raw_input
+ _raw_input = self.manager.kernel._sys_raw_input
prompt = msg['content']['prompt']
raw_print(prompt, end='')
- self.input(raw_input())
+ self.input(_raw_input())
class BlockingInProcessKernelManager(InProcessKernelManager):
View
@@ -84,7 +84,6 @@ def _eventloop_changed(self, name, old, new):
control_stream = Instance(ZMQStream)
iopub_socket = Instance(zmq.Socket)
stdin_socket = Instance(zmq.Socket)
- sys_raw_input = Any()
log = Instance(logging.Logger)
user_module = Any()
@@ -132,7 +131,11 @@ def _ident_default(self):
# This is a dict of port number that the kernel is listening on. It is set
# by record_ports and used by connect_request.
_recorded_ports = Dict()
-
+
+ # A reference to the Python builtin 'raw_input' function.
+ # (i.e., __builtin__.raw_input for Python 2.7, builtins.input for Python 3)
+ _sys_raw_input = Any()
+
# set of aborted msg_ids
aborted = Set()
@@ -353,10 +356,10 @@ def execute_request(self, stream, ident, parent):
raw_input = lambda prompt='' : self._no_raw_input()
if py3compat.PY3:
- self.sys_raw_input = __builtin__.input
+ self._sys_raw_input = __builtin__.input
__builtin__.input = raw_input
else:
- self.sys_raw_input = __builtin__.raw_input
+ self._sys_raw_input = __builtin__.raw_input
__builtin__.raw_input = raw_input
# Set the parent message of the display hook and out streams.
@@ -391,9 +394,9 @@ def execute_request(self, stream, ident, parent):
finally:
# Restore raw_input.
if py3compat.PY3:
- __builtin__.input = self.sys_raw_input
+ __builtin__.input = self._sys_raw_input
else:
- __builtin__.raw_input = self.sys_raw_input
+ __builtin__.raw_input = self._sys_raw_input
reply_content[u'status'] = status

0 comments on commit 36f98b6

Please sign in to comment.