mitsuhiko/werkzeug — Issue #157: Storing True and False in a RedisCache is broken
Author: aroberts
Created: 2012-01-23 21:54:13+00:00
State: open

Just recently got burned by improper deserialization of False in RedisCache. in `dump_object`, `False` gets serialized to `'False'` due to bool being a subclass of int. However, in `load_object`, `int('False')` raises an error, because False can't be cast to an int. This is mainly a problem when checking for false, as `'True'` evaluates with an affirmative truth value.

Here's a test highlighting the issue:

# werkzeug/testsuite/contrib/cache.py
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