Consistent interface to get text and bytes
Ouverte
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 1.7k
- Forks
- 408
- Merge moyen
- 2 j 57 min
- PR mergées (30 j)
- 7
Description
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>.
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 examiner les issues liées #610, #790 et #893, puis dressez l’inventaire des interfaces actuelles Oid, Object, TreeEntry et DiffLine décrites ici. Pour considérer le travail terminé, il faut arrêter la convention de nommage et la politique de conversion de text/bytes, puis résoudre les TODOs listés de manière cohérente dans tous les bindings.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- git, python
- Domaine
- api, backend-api-design, tooling
- Type d'issue
- Refactorisation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 20/100