Skip to content

Commit

Permalink
Fixed a bug of the redis cache with bools. This fixes pallets#157
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jan 24, 2012
1 parent e4db228 commit 1b69f3b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -11,6 +11,8 @@ Version 0.8.3
properly.
- Restore stdout after debug console finished executing so
that the debugger can be used on GAE better.
- Fixed a bug with the redis cache for int subclasses
(affects bool caching).

Version 0.8.2
-------------
Expand Down
3 changes: 2 additions & 1 deletion werkzeug/contrib/cache.py
Expand Up @@ -488,7 +488,8 @@ def dump_object(self, value):
"""Dumps an object into a string for redis. By default it serializes
integers as regular string and pickle dumps everything else.
"""
if isinstance(value, (int, long)):
t = type(value)
if t is int or t is long:
return str(value)
return '!' + pickle.dumps(value)

Expand Down
8 changes: 8 additions & 0 deletions werkzeug/testsuite/contrib/cache.py
Expand Up @@ -149,6 +149,14 @@ def test_inc_dec(self):
c.delete('foo')


def test_true_false(self):
c = self.make_cache()
c.set('foo', True)
assert c.get('foo') == True
c.set('bar', False)
assert c.get('bar') == False


def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SimpleCacheTestCase))
Expand Down

0 comments on commit 1b69f3b

Please sign in to comment.