[Django] #25838: ./manage.py shell creates unnecessary nested exceptions

6 views
Skip to first unread message

Django

unread,
Nov 30, 2015, 7:07:51 AM11/30/15
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: master
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Steps to reproduce (using Python 3):

* 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.

Django

unread,
Nov 30, 2015, 7:10:05 AM11/30/15
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Nov 30, 2015, 7:11:40 AM11/30/15
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 1, 2015, 8:23:16 AM12/1/15
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:3>

Django

unread,
Dec 13, 2015, 2:54:44 PM12/13/15
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jdufresne):

* cc: jon.dufresne@… (added)
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/25838#comment:4>

Django

unread,
Dec 22, 2015, 8:25:54 AM12/22/15
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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

Django

unread,
Jan 4, 2016, 2:43:31 AM1/4/16
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jan 4, 2016, 11:42:22 AM1/4/16
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jan 17, 2017, 10:09:52 PM1/17/17
to django-...@googlegroups.com
#25838: ./manage.py shell creates unnecessary nested exceptions
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: nobody

Type: | Status: closed
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages