Title: Offer error context manager for code.interact
Type: enhancement Stage: resolved
Components: Library (Lib) Versions:
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu Saftoiu, berker.peksag
Priority: normal Keywords:

Created on 2016-07-18 19:31 by Claudiu Saftoiu, last changed 2016-09-28 15:05 by berker.peksag. This issue is now closed.

Messages (2)
msg270786 - (view) Author: Claudiu Saftoiu (Claudiu Saftoiu) Date: 2016-07-18 19:31
When debugging code that raises unexpected exceptions, I often find myself doing this:

        import code; code.interact(local=locals())

My suggestion is a context manager to make this less verbose:

    with code.interact_on_error():

The effect would be the same: if an exception is caught, `code.interact` is called with the locals of the function, and re-raised when `code.interact` ends.
msg277635 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-28 15:05
Hi Claudiu, thanks for the report, but I don't think this is a common use case that needs to be supported in the standard library. Other people may prefer to use different solutions in a similar case (e.g. using a debugger) Plus, it's not hard to implement this as a custom context manager in your code.
Date User Action Args
2016-09-28 15:05:12berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg277635

resolution: rejected
stage: resolved
2016-07-18 19:31:04Claudiu Saftoiucreate