[Python-Dev] short-circuiting runtime errors/exceptions in python debugger.

Steven D'Aprano steve at pearwood.info
Fri Oct 26 19:48:07 EDT 2018


On Fri, Oct 26, 2018 at 04:18:37PM -0700, Ed Peschko wrote:
> all,
> 
> I was debugging a very long script that I was not all that familiar
> with, and I was doing my familiar routine of being very careful in
> evaluating expressions to make sure that I didn't hit such statements
> as:
> 
> TypeError: unsupported operand type(s) for +: 'int' and 'str'
> 
> anyways the script has a runtime of hours, so this was tedious work,
> and I hit one-too-many times where I missed a condition and had to
> start all over again.

Obviously you weren't careful enough :-)

You know you can set breakpoints in the debugger? You don't have to 
single-step all the way through from the beginning. It isn't clear from 
your post how experienced you are.


[...]
> So I was wondering if it would be possible to keep that context around
> if you are in the debugger and rewind the execution point to before
> the statement was triggered.

I think what you are looking for is a reverse debugger[1] also known as 
a time-travel debugger.

https://softwareengineering.stackexchange.com/questions/181527/why-is-reverse-debugging-rarely-used

There's a Python implementation, but I've never used it:

https://morepypy.blogspot.com/2016/07/reverse-debugging-for-python.html


[...]
> I can't emphasize exactly how much time and effort this would save.

That's what people say. But not everyone is a fan -- there are 
apparently memory consumption and stability issues with reverse 
debugging. There are people who love it, and those who don't.


> so - is this possible? just from my experiments it doesn't look so,
> but perhaps there is a trick out there that would give this
> functionality..
> 
> if it isn't possible, how easy would it be to implement?

If it isn't possible, it would be very difficult to implement :-)




[1] A reverse debugger is not the process of adding bugs to code *wink* 


-- 
Steve


More information about the Python-Dev mailing list