Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

bug with lists #12

@jabbalaci

Description

@jabbalaci

Hi,

Iteration over a list contains a bug:

N = 31

nums = get_list(key)

for i in range(N):
    nums.append(i)

back = [e for e in nums]

assert len(nums) == N
print(">> back's length:", len(back))
assert len(back) == N

Output:

>> back's length: 32
Traceback (most recent call last):
  File "./list_fails.py", line 35, in <module>
    fails()
  File "./list_fails.py", line 25, in fails
    assert len(back) == N
AssertionError

The problem is in this function: https://github.com/Doist/redis_wrap/blob/master/redis_wrap/redis_list.py#L41 . Whenever you add 30, you introduce a duplicate.

From the Redis docs (http://redis.io/commands/LRANGE):

"Note that if you have a list of numbers from 0 to 100, LRANGE list 0 10 will return 11 elements, that is, the rightmost item is included. This may or may not be consistent with behavior of range-related functions in your programming language of choice (think Ruby's Range.new, Array#slice or Python's range() function)."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions