Permalink
Browse files

Objects can still be pickled after a %reset.

  • Loading branch information...
1 parent 89f3d69 commit 5411be822c7463d180cb458abc5b1f1f8c19559e @takluyver committed Apr 14, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 IPython/core/interactiveshell.py
@@ -1059,24 +1059,25 @@ def reset(self, new_session=True):
# Restore the user namespaces to minimal usability
for ns in self.ns_refs_table:
ns.clear()
-
- # In some situations, e.g. testing, our fake main module has a __dict__
- # separate from the user_ns: if so, we need to clear it manually.
- if self.user_ns is not self.user_ns_mod.__dict__:
- self.user_ns_mod.__dict__.clear()
# The main execution namespaces must be cleared very carefully,
# skipping the deletion of the builtin-related keys, because doing so
# would cause errors in many object's __del__ methods.
for ns in [self.user_ns, self.user_global_ns]:
drop_keys = set(ns.keys())
+ drop_keys.discard('__name__')
drop_keys.discard('__builtin__')
drop_keys.discard('__builtins__')
for k in drop_keys:
del ns[k]
# Restore the user namespaces to minimal usability
self.init_user_ns()
+
+ # In some situations, e.g. testing, our fake main module has a __dict__
+ # separate from the user_ns: if so, we need to clear it manually.
+ if self.user_ns is not self.user_ns_mod.__dict__:
+ init_fakemod_dict(self.user_ns_mod, self.user_ns)
# Restore the default and user aliases
self.alias_manager.clear_aliases()

0 comments on commit 5411be8

Please sign in to comment.