-
-
Notifications
You must be signed in to change notification settings - Fork 403
Open
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 Patch: Add __str__ and __bytes__ for undecoded content. #790 (comment)) - 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>.
Metadata
Metadata
Assignees
Labels
No labels