Show More
@@ -113,6 +113,8 b' def softspace(file, newvalue):' | |||||
113 | return oldvalue |
|
113 | return oldvalue | |
114 |
|
114 | |||
115 |
|
115 | |||
|
116 | def no_op(*a, **kw): pass | |||
|
117 | ||||
116 | class SpaceInInput(exceptions.Exception): pass |
|
118 | class SpaceInInput(exceptions.Exception): pass | |
117 |
|
119 | |||
118 | class Bunch: pass |
|
120 | class Bunch: pass | |
@@ -1099,9 +1101,6 b' class InteractiveShell(Component, Magic):' | |||||
1099 | def savehist(self): |
|
1101 | def savehist(self): | |
1100 | """Save input history to a file (via readline library).""" |
|
1102 | """Save input history to a file (via readline library).""" | |
1101 |
|
1103 | |||
1102 | if not self.has_readline: |
|
|||
1103 | return |
|
|||
1104 |
|
||||
1105 | try: |
|
1104 | try: | |
1106 | self.readline.write_history_file(self.histfile) |
|
1105 | self.readline.write_history_file(self.histfile) | |
1107 | except: |
|
1106 | except: | |
@@ -1111,12 +1110,11 b' class InteractiveShell(Component, Magic):' | |||||
1111 | def reloadhist(self): |
|
1110 | def reloadhist(self): | |
1112 | """Reload the input history from disk file.""" |
|
1111 | """Reload the input history from disk file.""" | |
1113 |
|
1112 | |||
1114 | if self.has_readline: |
|
1113 | try: | |
1115 | try: |
|
1114 | self.readline.clear_history() | |
1116 |
|
|
1115 | self.readline.read_history_file(self.shell.histfile) | |
1117 | self.readline.read_history_file(self.shell.histfile) |
|
1116 | except AttributeError: | |
1118 | except AttributeError: |
|
1117 | pass | |
1119 | pass |
|
|||
1120 |
|
1118 | |||
1121 | def history_saving_wrapper(self, func): |
|
1119 | def history_saving_wrapper(self, func): | |
1122 | """ Wrap func for readline history saving |
|
1120 | """ Wrap func for readline history saving | |
@@ -1287,7 +1285,7 b' class InteractiveShell(Component, Magic):' | |||||
1287 | self.CustomTB(etype,value,tb) |
|
1285 | self.CustomTB(etype,value,tb) | |
1288 | else: |
|
1286 | else: | |
1289 | self.InteractiveTB(etype,value,tb,tb_offset=tb_offset) |
|
1287 | self.InteractiveTB(etype,value,tb,tb_offset=tb_offset) | |
1290 |
if self.InteractiveTB.call_pdb |
|
1288 | if self.InteractiveTB.call_pdb: | |
1291 | # pdb mucks up readline, fix it back |
|
1289 | # pdb mucks up readline, fix it back | |
1292 | self.set_completer() |
|
1290 | self.set_completer() | |
1293 | except KeyboardInterrupt: |
|
1291 | except KeyboardInterrupt: | |
@@ -1450,8 +1448,6 b' class InteractiveShell(Component, Magic):' | |||||
1450 |
|
1448 | |||
1451 | def set_completer_frame(self, frame=None): |
|
1449 | def set_completer_frame(self, frame=None): | |
1452 | """Set the frame of the completer.""" |
|
1450 | """Set the frame of the completer.""" | |
1453 | if not self.has_readline: |
|
|||
1454 | return |
|
|||
1455 | if frame: |
|
1451 | if frame: | |
1456 | self.Completer.namespace = frame.f_locals |
|
1452 | self.Completer.namespace = frame.f_locals | |
1457 | self.Completer.global_namespace = frame.f_globals |
|
1453 | self.Completer.global_namespace = frame.f_globals | |
@@ -1466,20 +1462,25 b' class InteractiveShell(Component, Magic):' | |||||
1466 | def init_readline(self): |
|
1462 | def init_readline(self): | |
1467 | """Command history completion/saving/reloading.""" |
|
1463 | """Command history completion/saving/reloading.""" | |
1468 |
|
1464 | |||
|
1465 | if self.readline_use: | |||
|
1466 | import IPython.utils.rlineimpl as readline | |||
|
1467 | ||||
1469 | self.rl_next_input = None |
|
1468 | self.rl_next_input = None | |
1470 | self.rl_do_indent = False |
|
1469 | self.rl_do_indent = False | |
1471 |
|
1470 | |||
1472 | if not self.readline_use: |
|
1471 | if not self.readline_use or not readline.have_readline: | |
1473 | return |
|
1472 | self.has_readline = False | |
1474 |
|
||||
1475 | import IPython.utils.rlineimpl as readline |
|
|||
1476 |
|
||||
1477 | if not readline.have_readline: |
|
|||
1478 | self.has_readline = 0 |
|
|||
1479 | self.readline = None |
|
1473 | self.readline = None | |
1480 | # no point in bugging windows users with this every time: |
|
1474 | # Set a number of methods that depend on readline to be no-op | |
1481 | warn('Readline services not available on this platform.') |
|
1475 | self.savehist = no_op | |
|
1476 | self.reloadhist = no_op | |||
|
1477 | self.set_completer = no_op | |||
|
1478 | self.set_custom_completer = no_op | |||
|
1479 | self.set_completer_frame = no_op | |||
|
1480 | warn('Readline services not available or not loaded.') | |||
1482 | else: |
|
1481 | else: | |
|
1482 | self.has_readline = True | |||
|
1483 | self.readline = readline | |||
1483 | sys.modules['readline'] = readline |
|
1484 | sys.modules['readline'] = readline | |
1484 | import atexit |
|
1485 | import atexit | |
1485 | from IPython.core.completer import IPCompleter |
|
1486 | from IPython.core.completer import IPCompleter | |
@@ -1514,8 +1515,6 b' class InteractiveShell(Component, Magic):' | |||||
1514 | warn('Problems reading readline initialization file <%s>' |
|
1515 | warn('Problems reading readline initialization file <%s>' | |
1515 | % inputrc_name) |
|
1516 | % inputrc_name) | |
1516 |
|
1517 | |||
1517 | self.has_readline = 1 |
|
|||
1518 | self.readline = readline |
|
|||
1519 | # save this in sys so embedded copies can restore it properly |
|
1518 | # save this in sys so embedded copies can restore it properly | |
1520 | sys.ipcompleter = self.Completer.complete |
|
1519 | sys.ipcompleter = self.Completer.complete | |
1521 | self.set_completer() |
|
1520 | self.set_completer() |
General Comments 0
You need to be logged in to leave comments.
Login now