Consistent interface to get text and bytes
Offen
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 1.7k
- Forks
- 408
- Ø Merge
- 2 T. 57 Min.
- Gemergte PRs (30 T.)
- 7
Beschreibung
Follow up from #610 #790 and #893
General policy:
- Do not implement
str() - To get unicode string use
.text - In
.textuse UTF-8 and replace (the rationale for replace is explained in https://github.com/libgit2/pygit2/pull/790#issuecomment-385906316) - To get the byte string use
.dataor.raw(this is to be decided) - For attributes the name of the attribute returns text, prefix with
raw_to get bytes. For instanceSignature.nameandSignature.raw_name - Implement the buffer protocol,
bytes(..)where appropriate
Open for discussion.
TODO:
- Replace
TreeEntry._nameby.raw_name - Replace
DiffLine.contentby.text - Inventory all the places where we get bytes, text, or the buffer protocol
- Settle on
.dataor.raw - Replace
DiffLine.raw_contentby.dataor.raw - Replace
Object.read_raw()by.data(or.raw), then removeBlob.data(it will inherit fromObject) - Settle on
str()bytes()and the buffer protocol
The case of Oid, what we've now:
oid.rawreturns the byte string (that's good, unless we decide to settle on.data)str(oid)andoid.hexboth return the hex representation, always<str>(bytes in Python 2 and text in Python 3)- Oid is the only place where we implement
str(...) Object.hexandTreeEntry.hexbehave the same, they return always<str>. Apparently these are the only places where we always return<str>.
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 der Durchsicht der verknüpften Issues #610, #790 und #893 und erfasse anschließend die hier beschriebenen aktuellen Schnittstellen Oid, Object, TreeEntry und DiffLine. Für den Abschluss müssen die Benennung und Konvertierungsrichtlinie für text/bytes festgelegt und die aufgeführten TODOs in allen Bindings konsistent bearbeitet werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- git, python
- Bereich
- api, backend-api-design, tooling
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 20/100