Show More
@@ -88,17 +88,12 b' class BuiltinTrap(Configurable):' | |||
|
88 | 88 | self._orig_builtins[key] = orig |
|
89 | 89 | bdict[key] = value |
|
90 | 90 | |
|
91 | def remove_builtin(self, key): | |
|
91 | def remove_builtin(self, key, orig): | |
|
92 | 92 | """Remove an added builtin and re-set the original.""" |
|
93 | try: | |
|
94 |
|
|
|
95 | except KeyError: | |
|
96 | pass | |
|
93 | if orig is BuiltinUndefined: | |
|
94 | del __builtin__.__dict__[key] | |
|
97 | 95 | else: |
|
98 | if orig is BuiltinUndefined: | |
|
99 | del __builtin__.__dict__[key] | |
|
100 | else: | |
|
101 | __builtin__.__dict__[key] = orig | |
|
96 | __builtin__.__dict__[key] = orig | |
|
102 | 97 | |
|
103 | 98 | def activate(self): |
|
104 | 99 | """Store ipython references in the __builtin__ namespace.""" |
@@ -115,11 +110,9 b' class BuiltinTrap(Configurable):' | |||
|
115 | 110 | def deactivate(self): |
|
116 | 111 | """Remove any builtins which might have been added by add_builtins, or |
|
117 | 112 | restore overwritten ones to their previous values.""" |
|
118 | # Note: must iterate over a static keys() list because we'll be | |
|
119 | # mutating the dict itself | |
|
120 | 113 | remove_builtin = self.remove_builtin |
|
121 |
for key in self._orig_builtins. |
|
|
122 | remove_builtin(key) | |
|
114 | for key, val in self._orig_builtins.iteritems(): | |
|
115 | remove_builtin(key, val) | |
|
123 | 116 | self._orig_builtins.clear() |
|
124 | 117 | self._builtins_added = False |
|
125 | 118 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now