diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index daee6ab..c08d91e 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -969,7 +969,7 @@ class InteractiveShell(SingletonConfigurable): # A record of hidden variables we have added to the user namespace, so # we can list later only variables defined in actual interactive use. - self.user_ns_hidden = set() + self.user_ns_hidden = {} # Now that FakeModule produces a real module, we've run into a nasty # problem: after script execution (via %run), the module where the user @@ -1300,7 +1300,8 @@ class InteractiveShell(SingletonConfigurable): # And configure interactive visibility user_ns_hidden = self.user_ns_hidden if interactive: - user_ns_hidden.difference_update(vdict) + for name in vdict: + user_ns_hidden.pop(name, None) else: user_ns_hidden.update(vdict) diff --git a/IPython/core/magics/namespace.py b/IPython/core/magics/namespace.py index 36f2d02..a469479 100644 --- a/IPython/core/magics/namespace.py +++ b/IPython/core/magics/namespace.py @@ -265,9 +265,10 @@ class NamespaceMagics(Magics): user_ns = self.shell.user_ns user_ns_hidden = self.shell.user_ns_hidden + nonmatching = object() # This can never be in user_ns out = [ i for i in user_ns if not i.startswith('_') \ - and not i in user_ns_hidden ] + and (user_ns[i] is not user_ns_hidden.get(i, nonmatching)) ] typelist = parameter_s.split() if typelist: