Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary .encode when writing to cache #24

Closed
wants to merge 1 commit into from

Conversation

wbernoudy
Copy link

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:

  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.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 56.738% when pulling 3b19a6b on wbernoudy:python3-cache-fix into 4616921 on Miserlou:master.

@bendog
Copy link
Collaborator

bendog commented Sep 12, 2019

I feel like there might be a reason for this, it might be for python <= 3.5 compatibility.

@bendog
Copy link
Collaborator

bendog commented Sep 12, 2019

replaced the code with non-breaking fix in #27

@bendog bendog closed this Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants