Skip to content

Murmur2Partitioner fails if given a bytearray key #428

@mutability

Description

@mutability

Murmur2Partitioner fails if given bytearray keys due to confusion between "key" and "data" vars:

Traceback (most recent call last):
[...]
  File "/usr/home/obj/.local/lib/python3.4/site-packages/kafka/producer/keyed.py", line 42, in send_messages
    partition = self._next_partition(topic, key)
  File "/usr/home/obj/.local/lib/python3.4/site-packages/kafka/producer/keyed.py", line 38, in _next_partition
    return partitioner.partition(key)
  File "/usr/home/obj/.local/lib/python3.4/site-packages/kafka/partitioner/hashed.py", line 15, in partition
    idx = (murmur2(key) & 0x7fffffff) % len(partitions)
  File "/usr/home/obj/.local/lib/python3.4/site-packages/kafka/partitioner/hashed.py", line 55, in murmur2
    length = len(data)
UnboundLocalError: local variable 'data' referenced before assignment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions