[yt-svn] commit/yt: brittonsmith: Attempting to fix inset_ipython function for ipython 0.11.

Bitbucket commits-noreply at bitbucket.org
Mon Nov 14 15:00:42 PST 2011


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/212866fe2532/
changeset:   212866fe2532
branch:      yt
user:        brittonsmith
date:        2011-11-15 00:00:35
summary:     Attempting to fix inset_ipython function for ipython 0.11.
affected #:  1 file

diff -r b6202dc21ecc0cce6bc33d3f365bf2a36f7279e5 -r 212866fe2532d4509f8df79f7ea9bf22f23a62ec yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -255,16 +255,32 @@
     *num_up* refers to how many frames of the stack get stripped off, and
     defaults to 1 so that this function itself is stripped off.
     """
-    from IPython.Shell import IPShellEmbed
+
+    import IPython
+    if IPython.__version__.startswith("0.10"):
+       api_version = '0.10'
+    elif IPython.__version__.startswith("0.11"):
+       api_version = '0.11'
+
     stack = inspect.stack()
     frame = inspect.stack()[num_up]
     loc = frame[0].f_locals.copy()
     glo = frame[0].f_globals
     dd = dict(fname = frame[3], filename = frame[1],
               lineno = frame[2])
-    ipshell = IPShellEmbed()
-    ipshell(header = __header % dd,
-            local_ns = loc, global_ns = glo)
+    if api_version == '0.10':
+        ipshell = IPython.Shell.IPShellEmbed()
+        ipshell(header = __header % dd,
+                local_ns = loc, global_ns = glo)
+    else:
+        from IPython.config.loader import Config
+        cfg = Config()
+        cfg.InteractiveShellEmbed.local_ns = loc
+        cfg.InteractiveShellEmbed.global_ns = glo
+        IPython.embed(config=cfg, banner2 = __header % dd)
+        from IPython.frontend.terminal.embed import InteractiveShellEmbed
+        ipshell = InteractiveShellEmbed(config=cfg)
+
     del ipshell

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list