Commit 250f1fc0 authored by kerash's avatar kerash

Fix boolean pickling

parent c1b64b7c
......@@ -211,7 +211,7 @@ class CacheClass(BaseCache):
timeout = self.default_timeout
# If ``value`` is not an int, then pickle it
if not isinstance(value, int):
if not isinstance(value, int) or isinstance(value, bool):
result = self._set(key, pickle.dumps(value), int(timeout), client, _add_only)
else:
result = self._set(key, value, int(timeout), client, _add_only)
......
......@@ -360,6 +360,12 @@ class RedisCacheTests(TestCase):
self.assertTrue(self.cache.set("foo", "1"))
self.assertEqual(self.cache.get("foo"), "1")
def test_setting_bool_retrieves_bool(self):
self.assertTrue(self.cache.set("bool_t", True))
self.assertEqual(self.cache.get("bool_t"), True)
self.assertTrue(self.cache.set("bool_f", False))
self.assertEqual(self.cache.get("bool_f"), False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment