Skip to content

Commit

Permalink
fix(set_message): encode strings if field is bytes
Browse files Browse the repository at this point in the history
Signed-off-by: Russ Webber <[email protected]>
  • Loading branch information
russkel committed Nov 2, 2024
1 parent 3327b1d commit faf19f3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rosidl_runtime_py/set_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def set_message_fields_internal(
value = numpy.array(field_value, dtype=field.dtype)
elif type(field_value) is field_type:
value = field_value
elif field_type is bytes and type(field_value) is str:
value = field_value.encode()
# We can't import these types directly, so we use the qualified class name to
# distinguish them from other fields
elif qualified_class_name == 'std_msgs.msg._header.Header' and \
Expand Down

0 comments on commit faf19f3

Please sign in to comment.