From 9656bf9c0739ce95f8ece318255c171b71d64d01 2013-05-07 00:41:55 From: MinRK Date: 2013-05-07 00:41:55 Subject: [PATCH] Don't rely on `get_ipython` in builtins in library code --- diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py index 2d440f8..d700034 100644 --- a/IPython/core/completerlib.py +++ b/IPython/core/completerlib.py @@ -33,7 +33,7 @@ from IPython.core.error import TryNext from IPython.utils._process_common import arg_split # FIXME: this should be pulled in with the right call via the component system -from IPython.core.ipapi import get as get_ipython +from IPython import get_ipython #----------------------------------------------------------------------------- # Globals and constants diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index ec65708..fbcd74a 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -31,6 +31,7 @@ import functools import linecache import sys +from IPython import get_ipython from IPython.utils import PyColorize, ulinecache from IPython.core import ipapi from IPython.utils import coloransi, io, py3compat @@ -113,9 +114,8 @@ class Tracer(object): from the Python standard library for usage details. """ - try: - ip = get_ipython() - except NameError: + ip = get_ipython() + if ip is None: # Outside of ipython, we set our own exception hook manually sys.excepthook = functools.partial(BdbQuit_excepthook, excepthook=sys.excepthook) diff --git a/IPython/lib/backgroundjobs.py b/IPython/lib/backgroundjobs.py index 3bf3460..839d6ca 100644 --- a/IPython/lib/backgroundjobs.py +++ b/IPython/lib/backgroundjobs.py @@ -33,6 +33,7 @@ use of the system. import sys import threading +from IPython import get_ipython from IPython.core.ultratb import AutoFormattedTB from IPython.utils.warn import error diff --git a/IPython/lib/editorhooks.py b/IPython/lib/editorhooks.py index b878fc5..593900e 100644 --- a/IPython/lib/editorhooks.py +++ b/IPython/lib/editorhooks.py @@ -8,6 +8,8 @@ Contributions are *very* welcome. import os import pipes import subprocess + +from IPython import get_ipython from IPython.core.error import TryNext