[Sugar-devel] [PATCH sugar-base] Add support for IPython 0.11+

Sascha Silbe silbe at activitycentral.com
Sun Jul 24 14:52:20 EDT 2011


From: Julian Taylor <jtaylor.debian at googlemail.com>

IPython 0.11 has changed API: AutoFormattedTB is now in IPython.core.ultratb,
not in IPython.ultraTB. We automatically fall back to the pre-0.11 names if
the 0.11 import statement fails.

[added comments, changed description]
Signed-off-by: Sascha Silbe <silbe at activitycentral.com>
Reviewed-by: Sascha Silbe <silbe at activitycentral.com>
---
 src/sugar/logger.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/sugar/logger.py b/src/sugar/logger.py
index 275c57d..21cd2c9 100644
--- a/src/sugar/logger.py
+++ b/src/sugar/logger.py
@@ -69,7 +69,13 @@ def _except_hook(exctype, value, traceback):
     # Attempt to provide verbose IPython tracebacks.
     # Importing IPython is slow, so we import it lazily.
     try:
-        from IPython.ultraTB import AutoFormattedTB
+        try:
+            # IPython 0.11+
+            from IPython.core.ultratb import AutoFormattedTB
+        except ImportError:
+            # IPython 0.10.2 and below
+            from IPython.ultraTB import AutoFormattedTB
+
         sys.excepthook = AutoFormattedTB(mode='Verbose',
             color_scheme='NoColor')
     except ImportError:
-- 
1.7.5.4



More information about the Sugar-devel mailing list