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