Support changing return value of a function in sys.monitoring
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 36k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Feature or enhancement
Proposal:
gdb has a command return for users to immediately return from the function. It basically does two things:
- stop the execution of the function
- return an arbitrary value
In Python, 1. might not be that simple as we have all the references to the stack value (it should be doable, but may or may not worth it), but 2. should be pretty straightforward. We can allow the callback for PY_RETURN function to return something specific (like sys.monitoring.RETURN, retval) to replace the value we are about to return. It should only need to swap the value on the stack and the impact should be contained. Some of the instrumentation structure needs to be refactored a bit but I don't think it's too much work.
With this feature, we can "mock" the return value in the debugger. We can even expand our existing return command - we may not able to return immediately, but we can run until it returns and secretly swap the return value, so we can call this command from anywhere.
Does this sound like a reasonable feature or I'm missing something? @markshannon
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par suivre le callback PY_RETURN de sys.monitoring et la structure d’instrumentation décrite dans la proposition. Comparez cela avec la commande de retour existante du débogueur, puis déterminez comment une valeur fournie par un callback pourrait remplacer la valeur de retour en attente. Le travail est considéré comme terminé lorsque le comportement est spécifié, implémenté et couvert par des tests permettant de modifier la valeur de retour d’une fonction.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- devtools
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 30/100