##// END OF EJS Templates
Complete fix for __del__ errors with .reset(), add unit test.
Fernando Perez -
Show More
@@ -983,11 +983,12 b' class InteractiveShell(Configurable, Magic):'
983 ns.clear()
983 ns.clear()
984
984
985 # The main execution namespaces must be cleared very carefully,
985 # The main execution namespaces must be cleared very carefully,
986 # skipping the deletion of the __builtin__ key, because doing so would
986 # skipping the deletion of the builtin-related keys, because doing so
987 # cause errors in many object's __del__ methods.
987 # would cause errors in many object's __del__ methods.
988 for ns in [self.user_ns, self.user_global_ns]:
988 for ns in [self.user_ns, self.user_global_ns]:
989 drop_keys = set(ns.keys())
989 drop_keys = set(ns.keys())
990 drop_keys.discard('__builtin__')
990 drop_keys.discard('__builtin__')
991 drop_keys.discard('__builtins__')
991 for k in drop_keys:
992 for k in drop_keys:
992 del ns[k]
993 del ns[k]
993
994
@@ -83,6 +83,22 b' def doctest_run_builtins():'
83 ....:
83 ....:
84 """
84 """
85
85
86 def doctest_reset_del():
87 """Test that resetting doesn't cause errors in __del__ methods.
88
89 In [2]: class A(object):
90 ...: def __del__(self):
91 ...: str("Hi")
92 ...:
93
94 In [3]: a = A()
95
96 In [4]: get_ipython().reset()
97
98 In [5]: 1+1
99 Out[5]: 2
100 """
101
86 # For some tests, it will be handy to organize them in a class with a common
102 # For some tests, it will be handy to organize them in a class with a common
87 # setup that makes a temp file
103 # setup that makes a temp file
88
104
General Comments 0
You need to be logged in to leave comments. Login now