Permalink
Browse files

Rename user_local_ns back to user_ns for simplicity.

  • Loading branch information...
1 parent 0f99efe commit ef23c605efdfca510d890583651c421479d103bf @takluyver committed Jul 29, 2011
Showing with 14 additions and 20 deletions.
  1. +12 −18 IPython/core/interactiveshell.py
  2. +2 −2 IPython/frontend/terminal/interactiveshell.py
@@ -372,7 +372,7 @@ def profile(self):
_post_execute = Instance(dict)
def __init__(self, config=None, ipython_dir=None, profile_dir=None,
- user_module=None, user_local_ns=None,
+ user_module=None, user_ns=None,
custom_exceptions=((), None)):
# This is where traits with a config_key argument are updated
@@ -387,7 +387,7 @@ def __init__(self, config=None, ipython_dir=None, profile_dir=None,
self.init_environment()
# Create namespaces (user_ns, user_global_ns, etc.)
- self.init_create_namespaces(user_module, user_local_ns)
+ self.init_create_namespaces(user_module, user_ns)
# This has to be done after init_create_namespaces because it uses
# something in self.user_ns, but before init_sys_modules, which
# is the first thing to modify sys.
@@ -639,17 +639,14 @@ def init_reload_doctest(self):
def save_sys_module_state(self):
"""Save the state of hooks in the sys module.
- This has to be called after self.user_ns is created.
+ This has to be called after self.user_module is created.
"""
self._orig_sys_module_state = {}
self._orig_sys_module_state['stdin'] = sys.stdin
self._orig_sys_module_state['stdout'] = sys.stdout
self._orig_sys_module_state['stderr'] = sys.stderr
self._orig_sys_module_state['excepthook'] = sys.excepthook
- try:
- self._orig_sys_modules_main_name = self.user_ns['__name__']
- except KeyError:
- pass
+ self._orig_sys_modules_main_name = self.user_module.__name__
def restore_sys_module_state(self):
"""Restore the state of the sys module."""
@@ -659,10 +656,7 @@ def restore_sys_module_state(self):
except AttributeError:
pass
# Reset what what done in self.init_sys_modules
- try:
- sys.modules[self.user_ns['__name__']] = self._orig_sys_modules_main_name
- except (AttributeError, KeyError):
- pass
+ sys.modules[self.user_module.__name__] = self._orig_sys_modules_main_name
#-------------------------------------------------------------------------
# Things related to hooks
@@ -860,7 +854,7 @@ def debugger(self,force=False):
# Things related to IPython's various namespaces
#-------------------------------------------------------------------------
- def init_create_namespaces(self, user_module=None, user_local_ns=None):
+ def init_create_namespaces(self, user_module=None, user_ns=None):
# Create the namespace where the user will operate. user_ns is
# normally the only one used, and it is passed to the exec calls as
# the locals argument. But we do carry a user_global_ns namespace
@@ -899,9 +893,9 @@ def init_create_namespaces(self, user_module=None, user_local_ns=None):
# properly initialized namespaces.
self.user_module = self.prepare_user_module(user_module)
- if user_local_ns is None:
- user_local_ns = self.user_module.__dict__
- self.user_local_ns = user_local_ns
+ if user_ns is None:
+ user_ns = self.user_module.__dict__
+ self.user_ns = user_ns
# An auxiliary namespace that checks what parts of the user_ns were
# loaded at startup, so we can list later only variables defined in
@@ -944,8 +938,8 @@ def init_create_namespaces(self, user_module=None, user_local_ns=None):
# A table holding all the namespaces IPython deals with, so that
# introspection facilities can search easily.
- self.ns_table = {'user_global':user_module.__dict__,
- 'user_local':user_local_ns,
+ self.ns_table = {'user_global':self.user_module.__dict__,
+ 'user_local':user_ns,
'internal':self.internal_ns,
'builtin':builtin_mod.__dict__
}
@@ -1073,7 +1067,7 @@ def init_user_ns(self):
# stuff, not our variables.
# Finally, update the real user's namespace
- self.user_local_ns.update(ns)
+ self.user_ns.update(ns)
def reset(self, new_session=True):
"""Clear all internal namespaces, and attempt to release references to
@@ -172,13 +172,13 @@ class TerminalInteractiveShell(InteractiveShell):
)
def __init__(self, config=None, ipython_dir=None, profile_dir=None, user_ns=None,
- user_global_ns=None, custom_exceptions=((),None),
+ user_module=None, custom_exceptions=((),None),
usage=None, banner1=None, banner2=None,
display_banner=None):
super(TerminalInteractiveShell, self).__init__(
config=config, profile_dir=profile_dir, user_ns=user_ns,
- user_global_ns=user_global_ns, custom_exceptions=custom_exceptions
+ user_module=user_module, custom_exceptions=custom_exceptions
)
# use os.system instead of utils.process.system by default,
# because piped system doesn't make sense in the Terminal:

0 comments on commit ef23c60

Please sign in to comment.