This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Pdb should restore the execution environment before reexecuting the target
Type: enhancement Stage:
Components: Library (Lib) Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: hexagonrecursion, iritkatriel
Priority: normal Keywords:

Created on 2020-11-17 11:54 by hexagonrecursion, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg381225 - (view) Author: Andrey Bienkowski (hexagonrecursion) * Date: 2020-11-17 11:54
When the target exits, pdb automatically restarts it. If the target changed something before exiting the changes will remain unless pdb explicitly undoes them. While working on #42383 I had an idea: it would be useful if pdb reverted the changes the target makes to the execution environment (to a reasonable extent) before restarting it. This includes:

1. os.getcwd() - currently not reverted
2. os.environ - I did not check if this is currently restored or not
3. sys.argv - --/--
4. sys.path - --/--
msg395808 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-14 16:23
I recently fixed a bug where breakpoints were not saved properly between reruns of the program - the assumption there was that if you set a breakpoint you don't want to have to set it again and again. 

Similarly, how do you know that the change to sys.path was made by the program rather than by a user from the debugger prompt?

It is easy enough to reset the state (just start a new debugger session) but if you want to restart the program with the env as it currently is, and you can't, it can be very annoying to have to re-apply all your settings again.
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86553
2021-06-14 16:23:22iritkatrielsettype: enhancement

messages: + msg395808
nosy: + iritkatriel
2020-11-17 11:54:28hexagonrecursioncreate