Skip to content

Commit ac20f17

Browse files
committed
fix(set_message): encode strings if field is bytes
1 parent 3327b1d commit ac20f17

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rosidl_runtime_py/set_message.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def set_message_fields_internal(
7070
value = numpy.array(field_value, dtype=field.dtype)
7171
elif type(field_value) is field_type:
7272
value = field_value
73+
elif field_type is bytes and type(field_value) is str:
74+
value = field_value.encode()
7375
# We can't import these types directly, so we use the qualified class name to
7476
# distinguish them from other fields
7577
elif qualified_class_name == 'std_msgs.msg._header.Header' and \

0 commit comments

Comments
 (0)