Is there any debugger that allows Python code to be changed while debugging?
In other words: run-time exception occurs, debugger stops, I change the code any way I like, and tell the program to continue.
I am aware of the problems with this approach, such that references to functions would still point to the old definitions if I redefine the function on the fly, and so on. I am ok with that, since I just want to be able to make small fixes in very simple circumstances.
On the other hand, I'm also interested in whether it's theoretically possible to allow changes to Python code without running into these problems: i.e., somehow update all the references to the objects that changed, etc. I'm nearly sure the answer to the second question is no, but if I'm wrong, I'd like to know.
EDIT: If my goal (changing the code interactively when an exception occurred, and then continuing execution), is achievable without a debugger - that would be good as well. I don't need to use the debugger.
解决方案
Since you can change the contents of regular classes the way you want at any time, there's no need to update references to objects: you just update class's __dict__ with new methods and other attributes.
The problem is with references to functions: you can't update a function without changing its identity. You can use proxy functions that always look up real functions by name, and you change real functions at any moment. Else, you plan your code so that it doesn't store function references for long; once a function is updated, it will soon be looked up by name, but old references passed somewhere will continue to execute for a bit longer.
Such patching would make sense on a long-running system when you want to upgrade it without serious downtime: you pause it for a moment to upgrade several classes and functions consistently and un-pause. AFAIK Erlang does its on-the-fly updates in a similar way.