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