redset
redset copied to clipboard
Bug: Timeout cannot be passed in as zero
https://github.com/percolate/redset/blob/master/redset/locks.py#L60
Because self.timeout is evaluated as timeout or 10, if timeout is passed in as 0, 0 is a false-y value, and incorrectly gets set to 10.
Let's just say an int of 0 or a float of 0.0 is an empty list/tuple/dict/set, an empty string or byte, a None (or in this case 0) are all falsey in Python, meaning they ultimately are all going to be evaluated as false.
This rule is fairly general. None, 0, [], {}, empty containers in general, etc., are all "falsey", while anything else is "truthy".
In [6]: bool(None)
Out[6]: False
In [7]: bool([])
Out[7]: False