redset icon indicating copy to clipboard operation
redset copied to clipboard

Bug: Timeout cannot be passed in as zero

Open jae-lee opened this issue 4 years ago • 1 comments

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.

jae-lee avatar Jan 06 '21 20:01 jae-lee

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

Montana avatar May 04 '22 17:05 Montana