microsoft / microsoft/vscode-python-debugger

Prevent vscode from exiting the Python interpreter a script completes

Aperta
#524 9 commenti 41 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature-request needs PR
Lingua principale
TypeScript
Stelle
181
Fork
126
Merge medio
2g 3h
PR unite (30g)
3

Descrizione

Discussed in https://github.com/microsoft/vscode-python/discussions/16082

Originally posted by larsoner April 29, 2021
The way I have used Python for years (through Spyder, directly from a bash terminal, etc.) is to execute a script in interactive mode such that once it's done, you can interact with it, e.g.:

python -i script.py

VSCode's debugger does not give a way to get this behavior currently. And it seems like I am not the only one looking for it:

One workaround is to put a breakpoint at the end of your file, but this requires extra work.

Another workaround is to add "env": {"PYTHONINSPECT": "true"}, to the launch configuration with integratedTerminal, but this doesn't work properly as any input is captured and newlines aren't treated properly while printing, which makes it pretty unusable.

I could see at least two potential solutions (the first would be better I think):

  1. Make it so that in PYTHONINSPECT mode, the terminal could be interacted with properly, possibly by adding a new inspectOnExit or something that ran in -i / PYTHONINSPECT mode and returned proper input/output when the script completes. Based on https://github.com/microsoft/vscode-python/issues/5497 it sounds like this is a no-go, though.
  2. Add a stopOnExit debug option to mirror stopOnEntry in the debugger. This way at least variables could be inspected using the vscode debugger.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Nell’issue non sono indicati file di implementazione né test. Inizia esaminando la discussione collegata e il comportamento esistente del debugger stopOnEntry, quindi confronta gli approcci interattivi proposti PYTHONINSPECT e stopOnExit con l’issue 5497. Done dovrebbe fornire un’esperienza utilizzabile di ispezione post-script senza richiedere un breakpoint alla fine.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
devtools
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.