You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Paho 2.0.0 mqtt Client can not publish bytearray payload
Reproduction
Calling paho.mqtt.client.Client.publish with payload as bytearray with qos = 1.
The publish method internally calls _encode_payload:
....
if not isinstance(payload, (bytes, bytearray)):
raise TypeError(
"payload must be a string, bytearray, int, float or None."
)
return payload
Then it calls _send_publish and the code blows up inside it: if payload and not isinstance(payload, bytes): raise TypeError('payload must be bytes if set')
Environment
Python version: 3.10
Library version: 2.0.0
Operating system (including version): MacOS 13.6.6
MQTT server (name, version, configuration, hosting details): mosquitto 2.0.11
Logs
client.publish(message.topic, message.payload, 1)
File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1798, in publish
rc = self._send_publish(message.mid, topic_bytes, message.payload, message.qos, message.retain,
File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3377, in _send_publish
raise TypeError('payload must be bytes if set')
The text was updated successfully, but these errors were encountered:
Bug Description
Paho 2.0.0 mqtt Client can not publish bytearray payload
Reproduction
Calling paho.mqtt.client.Client.publish with payload as bytearray with qos = 1.
The
publish
method internally calls_encode_payload
:Then it calls
_send_publish
and the code blows up inside it:if payload and not isinstance(payload, bytes): raise TypeError('payload must be bytes if set')
Environment
Logs
client.publish(message.topic, message.payload, 1)
File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1798, in publish
rc = self._send_publish(message.mid, topic_bytes, message.payload, message.qos, message.retain,
File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3377, in _send_publish
raise TypeError('payload must be bytes if set')
The text was updated successfully, but these errors were encountered: