Show More
@@ -22,13 +22,12 b' import __future__' | |||||
22 | import abc |
|
22 | import abc | |
23 | import atexit |
|
23 | import atexit | |
24 | import codeop |
|
24 | import codeop | |
25 | import exceptions |
|
|||
26 | import new |
|
|||
27 | import os |
|
25 | import os | |
28 | import re |
|
26 | import re | |
29 | import string |
|
27 | import string | |
30 | import sys |
|
28 | import sys | |
31 | import tempfile |
|
29 | import tempfile | |
|
30 | import types | |||
32 | from contextlib import nested |
|
31 | from contextlib import nested | |
33 |
|
32 | |||
34 | from IPython.config.configurable import Configurable |
|
33 | from IPython.config.configurable import Configurable | |
@@ -103,7 +102,7 b' def softspace(file, newvalue):' | |||||
103 |
|
102 | |||
104 | def no_op(*a, **kw): pass |
|
103 | def no_op(*a, **kw): pass | |
105 |
|
104 | |||
106 |
class SpaceInInput( |
|
105 | class SpaceInInput(Exception): pass | |
107 |
|
106 | |||
108 | class Bunch: pass |
|
107 | class Bunch: pass | |
109 |
|
108 | |||
@@ -521,7 +520,7 b' class InteractiveShell(Configurable, Magic):' | |||||
521 | def restore_sys_module_state(self): |
|
520 | def restore_sys_module_state(self): | |
522 | """Restore the state of the sys module.""" |
|
521 | """Restore the state of the sys module.""" | |
523 | try: |
|
522 | try: | |
524 | for k, v in self._orig_sys_module_state.items(): |
|
523 | for k, v in self._orig_sys_module_state.iteritems(): | |
525 | setattr(sys, k, v) |
|
524 | setattr(sys, k, v) | |
526 | except AttributeError: |
|
525 | except AttributeError: | |
527 | pass |
|
526 | pass | |
@@ -559,7 +558,7 b' class InteractiveShell(Configurable, Magic):' | |||||
559 | # accepts it. Probably at least check that the hook takes the number |
|
558 | # accepts it. Probably at least check that the hook takes the number | |
560 | # of args it's supposed to. |
|
559 | # of args it's supposed to. | |
561 |
|
560 | |||
562 |
f = |
|
561 | f = types.MethodType(hook,self) | |
563 |
|
562 | |||
564 | # check if the hook is for strdispatcher first |
|
563 | # check if the hook is for strdispatcher first | |
565 | if str_key is not None: |
|
564 | if str_key is not None: | |
@@ -1312,7 +1311,7 b' class InteractiveShell(Configurable, Magic):' | |||||
1312 | # The return value must be |
|
1311 | # The return value must be | |
1313 | return structured_traceback |
|
1312 | return structured_traceback | |
1314 |
|
1313 | |||
1315 |
This will be made into an instance method (via |
|
1314 | This will be made into an instance method (via types.MethodType) | |
1316 | of IPython itself, and it will be called if any of the exceptions |
|
1315 | of IPython itself, and it will be called if any of the exceptions | |
1317 | listed in the exc_tuple are caught. If the handler is None, an |
|
1316 | listed in the exc_tuple are caught. If the handler is None, an | |
1318 | internal basic one is used, which just prints basic info. |
|
1317 | internal basic one is used, which just prints basic info. | |
@@ -1333,7 +1332,7 b' class InteractiveShell(Configurable, Magic):' | |||||
1333 |
|
1332 | |||
1334 | if handler is None: handler = dummy_handler |
|
1333 | if handler is None: handler = dummy_handler | |
1335 |
|
1334 | |||
1336 |
self.CustomTB = |
|
1335 | self.CustomTB = types.MethodType(handler,self) | |
1337 | self.custom_exceptions = exc_tuple |
|
1336 | self.custom_exceptions = exc_tuple | |
1338 |
|
1337 | |||
1339 | def excepthook(self, etype, value, tb): |
|
1338 | def excepthook(self, etype, value, tb): | |
@@ -1675,8 +1674,7 b' class InteractiveShell(Configurable, Magic):' | |||||
1675 | The position argument (defaults to 0) is the index in the completers |
|
1674 | The position argument (defaults to 0) is the index in the completers | |
1676 | list where you want the completer to be inserted.""" |
|
1675 | list where you want the completer to be inserted.""" | |
1677 |
|
1676 | |||
1678 |
newcomp = |
|
1677 | newcomp = types.MethodType(completer,self.Completer) | |
1679 | self.Completer.__class__) |
|
|||
1680 | self.Completer.matchers.insert(pos,newcomp) |
|
1678 | self.Completer.matchers.insert(pos,newcomp) | |
1681 |
|
1679 | |||
1682 | def set_readline_completer(self): |
|
1680 | def set_readline_completer(self): | |
@@ -1752,7 +1750,7 b' class InteractiveShell(Configurable, Magic):' | |||||
1752 | """ |
|
1750 | """ | |
1753 |
|
1751 | |||
1754 | import new |
|
1752 | import new | |
1755 |
im = |
|
1753 | im = types.MethodType(func,self) | |
1756 | old = getattr(self, "magic_" + magicname, None) |
|
1754 | old = getattr(self, "magic_" + magicname, None) | |
1757 | setattr(self, "magic_" + magicname, im) |
|
1755 | setattr(self, "magic_" + magicname, im) | |
1758 | return old |
|
1756 | return old | |
@@ -2111,8 +2109,7 b' class InteractiveShell(Configurable, Magic):' | |||||
2111 | list.append(self, val) |
|
2109 | list.append(self, val) | |
2112 |
|
2110 | |||
2113 | import new |
|
2111 | import new | |
2114 |
self.input_hist.append = |
|
2112 | self.input_hist.append = types.MethodType(myapp, self.input_hist) | |
2115 | list) |
|
|||
2116 | # End dbg |
|
2113 | # End dbg | |
2117 |
|
2114 | |||
2118 | # All user code execution must happen with our context managers active |
|
2115 | # All user code execution must happen with our context managers active |
General Comments 0
You need to be logged in to leave comments.
Login now