From 030fc4686acf44b5ffe89a596451df0f0e0c91c5 2012-03-12 11:28:58 From: Scott Tsai Date: 2012-03-12 11:28:58 Subject: [PATCH] Move caller_module_and_locals() to IPython.util.frame --- diff --git a/IPython/__init__.py b/IPython/__init__.py index 3f030e2..6bf231b 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -49,6 +49,7 @@ from .core.error import TryNext from .core.interactiveshell import InteractiveShell from .testing import test from .utils.sysinfo import sys_info +from .utils.frame import caller_module_and_locals # Release data __author__ = '' @@ -57,13 +58,6 @@ for author, email in release.authors.itervalues(): __license__ = release.license __version__ = release.version -def caller_module_and_locals(): - """Returns (module, locals) of the caller""" - caller = sys._getframe(2) - global_ns = caller.f_globals - module = sys.modules[global_ns['__name__']] - return (module, caller.f_locals) - def embed_kernel(module=None, local_ns=None): """Call this to embed an IPython kernel at the current point in your program. """ (caller_module, caller_locals) = caller_module_and_locals() diff --git a/IPython/utils/frame.py b/IPython/utils/frame.py index 2fb6142..3b19072 100644 --- a/IPython/utils/frame.py +++ b/IPython/utils/frame.py @@ -85,3 +85,10 @@ def debugx(expr,pre_msg=''): # deactivate it by uncommenting the following line, which makes it a no-op #def debugx(expr,pre_msg=''): pass +def caller_module_and_locals(): + """Returns (module, locals) of the caller""" + caller = sys._getframe(2) + global_ns = caller.f_globals + module = sys.modules[global_ns['__name__']] + return (module, caller.f_locals) +