Make the capability of getting the source of interactive code public
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Feature or enhancement
Proposal:
In #117500, we create a nice mechanism to register and retrieve the source code of an arbitrary code object. It was a bug fix so we want to keep it as private as possible - it was for PyREPL usage only. However, we did put effort into the design so it can be used in a wider range in the future, and now is the future!
We just passed beta freeze so we have enough time to make it a new feature. The code and mechanism is really simple, it's just about documentation (and whether we want to merge some interfaces).
There are two orthogonal areas I want to bring into discussion, for each I have two proposals:
- How do we want the interface
- Keep it as it is, meaning the user needs to explicitly register and retrieve source code from a complete separate pair of interfaces.
- Combine
getlinesand_getline_from_code, making code an optional argument togetlines- take the path when the optional code object is passed in.
- How public do we want it to be
- Make it public to all users.
- Make it public internally so at least
inspectandpdbcan use it. (we don't document it, but we keepinspect.getsourcelineswork)
In either combination, we have the full backwards compatibility - nothing will be broken. It's more about how much maintenance effort we want to put in and how easy we want the user to use the feature.
An obvious example usage is that, if you want to debug some interactive code, either through pdb.run(), or debug command in pdb. You don't have the source code symbols now, even though it's fully available. With this capability, we can make pdb.run() work nicely with string source code.
cc: @pablogsal
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit PR #117500 und überprüfe den bestehenden Mechanismus zum Registrieren und Abrufen von interaktivem Quellcode. Vergleiche die vorgeschlagenen Schnittstellen getlines/_getline_from_code und berücksichtige, wie inspect und pdb sie verwenden würden. Als erledigt gilt die Auswahl der Schnittstelle und der Richtlinie zur öffentlichen Sichtbarkeit, die Dokumentation des Features, falls angemessen, sowie die Definition des erwarteten Verhaltens von pdb.run() oder des Debugging-Verhaltens.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100