summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-12-13 13:58:09 +0000
committerJannis Leidel <jannis@leidel.info>2010-12-13 13:58:09 +0000
commit2ab1e928540a4b38f5d3d639312e9978e0aa4363 (patch)
tree95c06296d71f363f696b795ef87ef1acd54696a9
parent4803410721db629a35390eb415e8c3fe86314f30 (diff)
[1.2.X] Fixed #12735 and #14892 -- Fixed support for the latest IPython (development) version in the shell management command.
Backport from trunk (r14895). git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14910 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/commands/shell.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
index 96169020e5..abb440e69a 100644
--- a/django/core/management/commands/shell.py
+++ b/django/core/management/commands/shell.py
@@ -23,11 +23,21 @@ class Command(NoArgsCommand):
if use_plain:
# Don't bother loading IPython, because the user wants plain Python.
raise ImportError
- import IPython
- # Explicitly pass an empty list as arguments, because otherwise IPython
- # would use sys.argv from this script.
- shell = IPython.Shell.IPShell(argv=[])
- shell.mainloop()
+ try:
+ from IPython.frontend.terminal.embed import TerminalInteractiveShell
+ shell = TerminalInteractiveShell()
+ shell.mainloop()
+ except ImportError:
+ # IPython < 0.11
+ # Explicitly pass an empty list as arguments, because otherwise
+ # IPython would use sys.argv from this script.
+ try:
+ from IPython.Shell import IPShell
+ shell = IPShell(argv=[])
+ shell.mainloop()
+ except ImportError:
+ # IPython not found at all, raise ImportError
+ raise
except ImportError:
import code
# Set up a dictionary to serve as the environment for the shell, so