> I'm porting some Kafka-using code from Python 2.7 to 3.6. My values > are Python dicts mapping strings to strings which are serialized with > json.dumps(). My keys are simple strings. I haven't been defining a > key serializer function. I'm using kafka_2.11-1.0.0 and kafka-python > 1.3.4 installed from conda-forge. (That appears to be the latest > version from there.) > > When sending a message, I get a TypeError which looks like this closed issue: > > https://github.com/dpkp/kafka-python/issues/1327
I think I figured this out. The output of the serializers must be a bytes object. Since str == bytes in Python 2, json.dumps was a perfectly good key and value serializer. That's not the case in Python 3. Another step is required to encode the resulting string as bytes. I suspect this is probably documented somewhere, but I've yet to find it. Pointers appreciated... Skip