arctic
arctic copied to clipboard
Reading Binary data back in py3 breaks
data = lib.read('gen:6447069510335728072', as_of='snap:6447069510335728072:fe9e74b04cee6a12').data
I get a bson.binary.Binary on 27-3 and TypeError: data must be an instance of bytes on 36-1. Similar items do read fine on 36-1, returning a bytes
My guess is that this is happening due to the type of what's being stored inside the Binary. eg. a str when loaded back in py3 breaks as the bson.binary.Binary constructor. eg:
In [1]: import bson, pickle
In [2]: s = bson.binary.Binary('a')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-b90cb3c1049b> in <module>()
----> 1 s = bson.binary.Binary('a')
/users/is/ahlpypi/medusa_egg_cache/36-1/p/pymongo-3.6.0-py3.6-linux-x86_64.egg/bson/binary.py in __new__(cls, data, subtype)
145 def __new__(cls, data, subtype=BINARY_SUBTYPE):
146 if not isinstance(data, bytes):
--> 147 raise TypeError("data must be an instance of bytes")
148 if not isinstance(subtype, int):
149 raise TypeError("subtype must be an instance of int")
TypeError: data must be an instance of bytes
In [3]: s = bson.binary.Binary(b'a')
In [4]: 'a'
Out[4]: 'a'