[Sugar-devel] [PATCH sugar-base] Add support for IPython 0.11+
Simon Schampijer
simon at schampijer.de
Wed Jul 27 06:17:11 EDT 2011
On 07/24/2011 08:52 PM, Sascha Silbe wrote:
> 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:
The outer try does check for an import error as well. Maybe it is
clearer to do:
try:
# IPython 0.11+
from IPython.core.ultratb import AutoFormattedTB
except ImportError:
# IPython 0.10.2 and below
try:
from IPython.ultraTB import AutoFormattedTB
except ImportError:
sys.excepthook = sys.__excepthook__
Otherwise looks good.
Regards,
Simon
More information about the Sugar-devel
mailing list