Show More
@@ -74,10 +74,10 class BlockingStdInInProcessChannel(BlockingChannelMixin, StdInInProcessChannel) | |||||
74 | """ |
|
74 | """ | |
75 | msg_type = msg['header']['msg_type'] |
|
75 | msg_type = msg['header']['msg_type'] | |
76 | if msg_type == 'input_request': |
|
76 | if msg_type == 'input_request': | |
77 | raw_input = self.manager.kernel.sys_raw_input |
|
77 | _raw_input = self.manager.kernel._sys_raw_input | |
78 | prompt = msg['content']['prompt'] |
|
78 | prompt = msg['content']['prompt'] | |
79 | raw_print(prompt, end='') |
|
79 | raw_print(prompt, end='') | |
80 | self.input(raw_input()) |
|
80 | self.input(_raw_input()) | |
81 |
|
81 | |||
82 | class BlockingInProcessKernelManager(InProcessKernelManager): |
|
82 | class BlockingInProcessKernelManager(InProcessKernelManager): | |
83 |
|
83 |
@@ -84,7 +84,6 class Kernel(Configurable): | |||||
84 | control_stream = Instance(ZMQStream) |
|
84 | control_stream = Instance(ZMQStream) | |
85 | iopub_socket = Instance(zmq.Socket) |
|
85 | iopub_socket = Instance(zmq.Socket) | |
86 | stdin_socket = Instance(zmq.Socket) |
|
86 | stdin_socket = Instance(zmq.Socket) | |
87 | sys_raw_input = Any() |
|
|||
88 | log = Instance(logging.Logger) |
|
87 | log = Instance(logging.Logger) | |
89 |
|
88 | |||
90 | user_module = Any() |
|
89 | user_module = Any() | |
@@ -132,7 +131,11 class Kernel(Configurable): | |||||
132 | # This is a dict of port number that the kernel is listening on. It is set |
|
131 | # This is a dict of port number that the kernel is listening on. It is set | |
133 | # by record_ports and used by connect_request. |
|
132 | # by record_ports and used by connect_request. | |
134 | _recorded_ports = Dict() |
|
133 | _recorded_ports = Dict() | |
135 |
|
134 | |||
|
135 | # A reference to the Python builtin 'raw_input' function. | |||
|
136 | # (i.e., __builtin__.raw_input for Python 2.7, builtins.input for Python 3) | |||
|
137 | _sys_raw_input = Any() | |||
|
138 | ||||
136 | # set of aborted msg_ids |
|
139 | # set of aborted msg_ids | |
137 | aborted = Set() |
|
140 | aborted = Set() | |
138 |
|
141 | |||
@@ -353,10 +356,10 class Kernel(Configurable): | |||||
353 | raw_input = lambda prompt='' : self._no_raw_input() |
|
356 | raw_input = lambda prompt='' : self._no_raw_input() | |
354 |
|
357 | |||
355 | if py3compat.PY3: |
|
358 | if py3compat.PY3: | |
356 | self.sys_raw_input = __builtin__.input |
|
359 | self._sys_raw_input = __builtin__.input | |
357 | __builtin__.input = raw_input |
|
360 | __builtin__.input = raw_input | |
358 | else: |
|
361 | else: | |
359 | self.sys_raw_input = __builtin__.raw_input |
|
362 | self._sys_raw_input = __builtin__.raw_input | |
360 | __builtin__.raw_input = raw_input |
|
363 | __builtin__.raw_input = raw_input | |
361 |
|
364 | |||
362 | # Set the parent message of the display hook and out streams. |
|
365 | # Set the parent message of the display hook and out streams. | |
@@ -391,9 +394,9 class Kernel(Configurable): | |||||
391 | finally: |
|
394 | finally: | |
392 | # Restore raw_input. |
|
395 | # Restore raw_input. | |
393 | if py3compat.PY3: |
|
396 | if py3compat.PY3: | |
394 | __builtin__.input = self.sys_raw_input |
|
397 | __builtin__.input = self._sys_raw_input | |
395 | else: |
|
398 | else: | |
396 | __builtin__.raw_input = self.sys_raw_input |
|
399 | __builtin__.raw_input = self._sys_raw_input | |
397 |
|
400 | |||
398 | reply_content[u'status'] = status |
|
401 | reply_content[u'status'] = status | |
399 |
|
402 |
General Comments 0
You need to be logged in to leave comments.
Login now