diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 66610b1..0055887 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -28,8 +28,13 @@ import runpy import sys import tempfile import types -import urllib -from io import open as io_open + +# We need to use nested to support python 2.6, once we move to >=2.7, we can +# use the with keyword's new builtin support for nested managers +try: + from contextlib import nested +except: + from IPython.utils.nested_context import nested from IPython.config.configurable import SingletonConfigurable from IPython.core import debugger, oinspect diff --git a/IPython/frontend/terminal/embed.py b/IPython/frontend/terminal/embed.py index f1430a7..f6506ee 100644 --- a/IPython/frontend/terminal/embed.py +++ b/IPython/frontend/terminal/embed.py @@ -25,9 +25,15 @@ Notes from __future__ import with_statement import sys -from contextlib import nested import warnings +# We need to use nested to support python 2.6, once we move to >=2.7, we can +# use the with keyword's new builtin support for nested managers +try: + from contextlib import nested +except: + from IPython.utils.nested_context import nested + from IPython.core import ultratb from IPython.core.magic import Magics, magics_class, line_magic from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell diff --git a/IPython/frontend/terminal/interactiveshell.py b/IPython/frontend/terminal/interactiveshell.py index 1086edd..5ddbccc 100644 --- a/IPython/frontend/terminal/interactiveshell.py +++ b/IPython/frontend/terminal/interactiveshell.py @@ -20,7 +20,12 @@ import re import sys import textwrap -from contextlib import nested +# We need to use nested to support python 2.6, once we move to >=2.7, we can +# use the with keyword's new builtin support for nested managers +try: + from contextlib import nested +except: + from IPython.utils.nested_context import nested from IPython.core.error import TryNext, UsageError from IPython.core.usage import interactive_usage, default_banner