@@ -156,11 +156,11 @@ def send_messages(self, topic, partition, *msg):
156
156
Helper method to send produce requests
157
157
@param: topic, name of topic for produce request -- type str
158
158
@param: partition, partition number for produce request -- type int
159
- @param: *msg, one or more message payloads -- type str
159
+ @param: *msg, one or more message payloads -- type bytes
160
160
@returns: ResponseRequest returned by server
161
161
raises on error
162
162
163
- Note that msg type *must* be encoded to str by user.
163
+ Note that msg type *must* be encoded to bytes by user.
164
164
Passing unicode message will not work, for example
165
165
you should encode before calling send_messages via
166
166
something like `unicode_message.encode('utf-8')`
@@ -172,9 +172,9 @@ def send_messages(self, topic, partition, *msg):
172
172
if not isinstance (msg , (list , tuple )):
173
173
raise TypeError ("msg is not a list or tuple!" )
174
174
175
- # Raise TypeError if any message is not encoded as a str
176
- if any (not isinstance (m , str ) for m in msg ):
177
- raise TypeError ("all produce message payloads must be type str " )
175
+ # Raise TypeError if any message is not encoded as bytes
176
+ if any (not isinstance (m , bytes ) for m in msg ):
177
+ raise TypeError ("all produce message payloads must be type bytes " )
178
178
179
179
if self .async :
180
180
for m in msg :
0 commit comments