diff options
author | Dana Powers <dana.powers@gmail.com> | 2018-03-10 10:27:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-10 10:27:05 -0500 |
commit | b8d40b52b4142b97a8797d809cc3b042cec4877f (patch) | |
tree | b1bf63dc9634b668db025360678e753fd22bd6bc | |
parent | 22e3f75e92a791b3a42cac2a87b19ec33a4ca351 (diff) | |
download | kafka-python-b8d40b52b4142b97a8797d809cc3b042cec4877f.tar.gz |
Validate that serializers generate bytes-like (or None) data (#1420)
-rw-r--r-- | kafka/producer/kafka.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index 52c0953..f285ab4 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -540,8 +540,6 @@ class KafkaProducer(object): assert not (value is None and key is None), 'Need at least one: key or value' key_bytes = value_bytes = None try: - # first make sure the metadata for the topic is - # available self._wait_on_metadata(topic, self.config['max_block_ms'] / 1000.0) key_bytes = self._serialize( @@ -550,6 +548,9 @@ class KafkaProducer(object): value_bytes = self._serialize( self.config['value_serializer'], topic, value) + assert type(key_bytes) in (bytes, bytearray, memoryview, type(None)) + assert type(value_bytes) in (bytes, bytearray, memoryview, type(None)) + partition = self._partition(topic, partition, key, value, key_bytes, value_bytes) |