Skip to content

Commit

Permalink
None safety
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Oct 8, 2019
1 parent ddb8c4f commit 336c0a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/relstorage/cache/cache.pyx
Expand Up @@ -482,18 +482,18 @@ cdef class PyCache:
def __setitem__(self, OID_t key, tuple value):
# Do all this down here so we don't give up the GIL.
cdef TID_t tid = value[1]

state = value[0] or b''
if not self.cache.contains(key): # the long way to avoid type conversion
self.cache.add_to_eden(
key,
PyBytes_AsString(value[0] or b''),
len(value[0]),
PyBytes_AsString(state),
len(state),
tid
)
else:
# We need to merge values.
try:
self.cache.store_and_make_MRU(key, PyBytes_AsString(value[0]), len(value[0]), tid)
self.cache.store_and_make_MRU(key, PyBytes_AsString(state), len(state), tid)
except RuntimeError as e:
raise CacheConsistencyError(str(e))

Expand Down

0 comments on commit 336c0a3

Please sign in to comment.