All naked excepts which raise an exception should include previous exception stack
|Reported by:||Owned by:||Jake Rothenbuhler|
|Cc:||ognajd@…, hv@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I propose that there should be a strict policy for any new code being committed and all old code as it is found to be offending that any where there is a naked except, that is an except block that catches all exceptions, and an exception is raised within this block, that the previous exceptions exception call stack be preserved in the new raised exception.
For example, in contrib/admin/views/main.py on line 319 there is a naked except and the caught exception object is wrapped by another exception class and then re-raised. This loses the call stack of the originating exception, thus making it potentially very difficult to debug the original exception.
This issue should fix the above and start a policy discussion.
Change History (9)
comment:1 Changed 5 years ago by
|Patch needs improvement:||unset|
comment:2 Changed 5 years ago by
|Component:||Uncategorized → Core (Other)|
|Summary:||NEW POLICY: All naked excepts which raise an exception should include previous exception stack. → All naked excepts which raise an exception should include previous exception stack|
|Triage Stage:||Unreviewed → Accepted|
|Type:||Bug → Cleanup/optimization|