classification
Title: Command-line option to suppress "from None" for debugging
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mariatta, rhettinger, serhiy.storchaka, wolma
Priority: normal Keywords:

Created on 2017-04-18 22:11 by rhettinger, last changed 2017-04-20 10:20 by wolma.

Messages (2)
msg291844 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-04-18 22:11
Filing this feature request on behalf of an engineering team that I work with.

This team creates Python tools for use by other departments.  Accordingly, their best practice is to use "raise CleanException from None" to give the cleanest error messages to their users while hiding the noise of implementation details and internal logic.  The exposed exceptions are a documented, guaranteed part of the API that users can reliably catch and handle.  This has worked well for them; however, when they are debugging the library itself it would be nice to have a way to suppress all the "from None" code and see fuller stack traces that indicate root causes.

One way to do this would be to have a command-line switch such as "python -C testcode.py".   Where the "-C" option means "Always show the cause of exceptions even when 'from None' is present.
msg291857 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-19 04:06
The initial exception still is linked as __context__. You can write own implementation of traceback.print_exception() that ignores __suppress_context__. Alternatively you can just set __suppress_context__ to False.
History
Date User Action Args
2017-04-20 10:20:54wolmasetnosy: + wolma
2017-04-19 04:39:15Mariattasetnosy: + Mariatta
2017-04-19 04:06:52serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg291857
2017-04-18 22:11:52rhettingercreate