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

Sascha Silbe sascha-ml-reply-to-2011-4 at silbe.org
Tue Dec 20 08:53:44 EST 2011


Excerpts from Simon Schampijer's message of 2011-07-27 12:17:11 +0200:

> 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__

In its entirety, this would be:

    try:
        # IPython 0.11+
        from IPython.core.ultratb import AutoFormattedTB
        sys.excepthook = AutoFormattedTB(mode='Verbose',
                                         color_scheme='NoColor')
    except ImportError:
        # IPython 0.10.2 and below
        try:
            from IPython.ultraTB import AutoFormattedTB
            sys.excepthook = AutoFormattedTB(mode='Verbose',
                                             color_scheme='NoColor')
        except ImportError:
            sys.excepthook = sys.__excepthook__


I still prefer Julians version, because it omits the duplicate
AutoformattedTB instantiation / assignment:

    try:
        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:
        sys.excepthook = sys.__excepthook__


But I don't mind it much and will push whatever you prefer.

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20111220/87bb2b51/attachment.pgp>


More information about the Sugar-devel mailing list