* Open a python shell with ./manage.py shell
* raise an exception with `raise Exception`
Notice how the exception is nested with another one:
{{{#!py
>>> raise Exception
Traceback (most recent call last):
File "./django/core/management/commands/shell.py", line 67, in handle
raise ImportError
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<console>", line 1, in <module>
Exception
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25838>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by bmispelon):
Changing the logic in `core/management/shell.py` from
{{{#!py
try:
if options['plain']:
# Don't bother loading IPython, because the user wants plain
Python.
raise ImportError
self.run_shell(shell=options['interface'])
except ImportError:
# do a bunch of stuff
}}}
to:
{{{#!py
try:
if options['plain']:
# Don't bother loading IPython, because the user wants plain
Python.
raise ImportError
self.run_shell(shell=options['interface'])
except ImportError:
pass
else:
return
# do a bunch of stuff
}}}
Seems to fix the issue for me
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:1>
Comment (by apollo13):
I'd rather add "plain" to the list of available shells all time, so we
just need a simple loop over all the shells (if "plain" is always added as
last one, there should be no need for extra fallback handling etc…)
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:2>
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:3>
* cc: jon.dufresne@… (added)
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:4>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"f1628f6be1b8113b5e53aea497b2f6c47180e83f" f1628f6]:
{{{
#!CommitTicketReference repository=""
revision="f1628f6be1b8113b5e53aea497b2f6c47180e83f"
Fixed #25838 -- Added "python" as an interface to the shell command.
Deprecates the "--plain" option.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:5>
Comment (by cjerdonek):
Thanks for fixing this! To prevent regressions, should a test also have
been added checking that the exception chain doesn't have spurious
entries?
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:6>
Comment (by timgraham):
I'm not sure if the `shell` command can be tested, currently it doesn't
have any tests. Maybe it would be feasible after #25680 is fixed, but the
risk of this regression seems low, especially because this command doesn't
receive much innovation.
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"f65b1aee71dfb17dcf5738545db3f3fdf980fe72" f65b1ae]:
{{{
#!CommitTicketReference repository=""
revision="f65b1aee71dfb17dcf5738545db3f3fdf980fe72"
Refs #25838 -- Removed the deprecated shell --plain option.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:8>