Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
code.interact() is provided as a method to embed an interactive shell in arbitrary python code. It was used inpdb forinteract command.
However, when the user needs to exit, they probably will use a very familiar commandexit() (orquit()), then they'll realize that the whole process is terminated. In most of the cases, that's not the expected bahavior. The user probably just wants to exit the interpreter and go back to the original code.
Ctrl+D(Ctrl+Z then enter) works as expected because there's logic to handle that specifically.
Simply catchingSystemExit won't work becausebuiltins.exit() andbuiltins.quit() (if provided) will also closesys.stdin (weird behavior to me) and it's not trivial to reopenstdin.
To provide a more reasonable and unified behavior, we can replace theexit andquit inbuiltins in the interactive shell, and switch back after. This will also makepdb happier.