##// END OF EJS Templates
Simplify logic (semantics unchanged) in builtins trap.
Fernando Perez -
Show More
@@ -88,13 +88,8 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 orig = self._orig_builtins.pop(key)
95 except KeyError:
96 pass
97 else:
98 93 if orig is BuiltinUndefined:
99 94 del __builtin__.__dict__[key]
100 95 else:
@@ -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.keys():
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