#25838 closed Cleanup/optimization (fixed)
./manage.py shell creates unnecessary nested exceptions
Reported by: | Baptiste Mispelon | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | jon.dufresne@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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:
>>> 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
Change History (8)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
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…)
comment:3 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Bug → Cleanup/optimization |
comment:4 by , 9 years ago
Cc: | added |
---|---|
Has patch: | set |
comment:6 by , 9 years ago
Thanks for fixing this! To prevent regressions, should a test also have been added checking that the exception chain doesn't have spurious entries?
comment:7 by , 9 years ago
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.
Changing the logic in
core/management/shell.py
fromto:
Seems to fix the issue for me