Skip to content

Commit 21f7fda

Browse files
author
Kurt Yoder
authored
Merge pull request #76 from einarf/cache-bytes
Bug: Earlier py3 versions do not support json as bytes
2 parents 291c5e9 + dd9ce97 commit 21f7fda

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/test_cache.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,18 @@ def __exit__(self, *args):
167167

168168
def read(self, length=-1):
169169
if length == -1:
170-
return self.data.read()
170+
if 'b' in self.mode:
171+
return self.data.read()
171172

172-
return self.data.read(length)
173+
return self.data.read().decode('utf-8')
174+
175+
if 'b' in self.mode:
176+
return self.data.read(length)
177+
178+
return self.data.read(length).decode('utf-8')
173179

174180
def write(self, data):
175-
if not 'b' in self.mode:
181+
if 'b' not in self.mode:
176182
data = data.encode()
177183

178184
self.data.write(data)

0 commit comments

Comments
 (0)