The body of an object is read in as bytes in python 3 (at least sometimes?). When the cache option is on, NoDB will then attempt to call .encode() on these bytes and then write that to the cache file. However this method was removed in python 3, so error something like:
File "/opt/conda/lib/python3.6/site-packages/nodb/__init__.py", line 145, in load
in_file.write(serialized.encode(self.encoding))
AttributeError: 'bytes' object has no attribute 'encode'
is raised.
Solution
I think simply removing the .encode() should be fine, as python 2/3 can write bytes or str to a file just fine. Let me know if I have misunderstood what that line is supposed to be doing.
Coverage remained the same at 56.738% when pulling 3b19a6b28399f0f6eb6066c30c22bad745964b2e on wbernoudy:python3-cache-fix into 46169217e84b6e72c17a94ef96e3bf84183d45bc on Miserlou:master.
Issue
The body of an object is read in as bytes in python 3 (at least sometimes?). When the cache option is on, NoDB will then attempt to call
.encode()
on these bytes and then write that to the cache file. However this method was removed in python 3, so error something like:is raised.
Solution
I think simply removing the
.encode()
should be fine, as python 2/3 can write bytes or str to a file just fine. Let me know if I have misunderstood what that line is supposed to be doing.