Show More
@@ -282,67 +282,6 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
282 | 282 | # Turn off the exit flag, so the mainloop can be restarted if desired |
|
283 | 283 | self.exit_now = False |
|
284 | 284 | |
|
285 | def raw_input(self, prompt='', continue_prompt=False): | |
|
286 | """Write a prompt and read a line. | |
|
287 | ||
|
288 | The returned line does not include the trailing newline. | |
|
289 | When the user enters the EOF key sequence, EOFError is raised. | |
|
290 | ||
|
291 | Optional inputs: | |
|
292 | ||
|
293 | - prompt(''): a string to be printed to prompt the user. | |
|
294 | ||
|
295 | - continue_prompt(False): whether this line is the first one or a | |
|
296 | continuation in a sequence of inputs. | |
|
297 | """ | |
|
298 | # Code run by the user may have modified the readline completer state. | |
|
299 | # We must ensure that our completer is back in place. | |
|
300 | ||
|
301 | if self.has_readline: | |
|
302 | self.set_readline_completer() | |
|
303 | ||
|
304 | try: | |
|
305 | line = raw_input_original(prompt).decode(self.stdin_encoding) | |
|
306 | except ValueError: | |
|
307 | warn("\n********\nYou or a %run:ed script called sys.stdin.close()" | |
|
308 | " or sys.stdout.close()!\nExiting IPython!") | |
|
309 | self.ask_exit() | |
|
310 | return "" | |
|
311 | ||
|
312 | # Try to be reasonably smart about not re-indenting pasted input more | |
|
313 | # than necessary. We do this by trimming out the auto-indent initial | |
|
314 | # spaces, if the user's actual input started itself with whitespace. | |
|
315 | if self.autoindent: | |
|
316 | if num_ini_spaces(line) > self.indent_current_nsp: | |
|
317 | line = line[self.indent_current_nsp:] | |
|
318 | self.indent_current_nsp = 0 | |
|
319 | ||
|
320 | # store the unfiltered input before the user has any chance to modify | |
|
321 | # it. | |
|
322 | if line.strip(): | |
|
323 | if continue_prompt: | |
|
324 | if self.has_readline and self.readline_use: | |
|
325 | histlen = self.readline.get_current_history_length() | |
|
326 | if histlen > 1: | |
|
327 | newhist = self.history_manager.input_hist_raw[-1].rstrip() | |
|
328 | self.readline.remove_history_item(histlen-1) | |
|
329 | self.readline.replace_history_item(histlen-2, | |
|
330 | newhist.encode(self.stdin_encoding)) | |
|
331 | else: | |
|
332 | self.history_manager.input_hist_raw.append('%s\n' % line) | |
|
333 | elif not continue_prompt: | |
|
334 | self.history_manager.input_hist_raw.append('\n') | |
|
335 | try: | |
|
336 | lineout = self.prefilter_manager.prefilter_lines(line,continue_prompt) | |
|
337 | except: | |
|
338 | # blanket except, in case a user-defined prefilter crashes, so it | |
|
339 | # can't take all of ipython with it. | |
|
340 | self.showtraceback() | |
|
341 | return '' | |
|
342 | else: | |
|
343 | return lineout | |
|
344 | ||
|
345 | ||
|
346 | 285 | def raw_input(self, prompt=''): |
|
347 | 286 | """Write a prompt and read a line. |
|
348 | 287 |
General Comments 0
You need to be logged in to leave comments.
Login now