-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
We could add __bytes__ to ObjectId to support bytes(oid) in Python 3. Currently this is not supported:
>>> bytes(ObjectId()) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot convert 'ObjectId' object to bytes
The implementation can just be an alias for the binary property:
class ObjectId(object): ... def __bytes__(self): return self.binary
This was requested in PYTHON-1843.
- is related to
-
PYTHON-1843 BSON C module directly accesses private attributes.
- Closed