All naked excepts which raise an exception should include previous exception stack
|Reported by:||Glenn Washburn <devlopment@…>||Owned by:||jrothenbuhler|
|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 2 years ago by Glenn Washburn <devlopment@…>
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 2 years ago by jezdez
- Component changed from Uncategorized to Core (Other)
- Summary changed from NEW POLICY: All naked excepts which raise an exception should include previous exception stack. to All naked excepts which raise an exception should include previous exception stack
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Bug to Cleanup/optimization