ros2 / ros2/rosidl_python

byte[] AKA IDL sequence<octet> fields required to be sequence of bytes instances instead of bytes instance

Open
#134 3 comments 2 reactions 0 assignees View on GitHub

@aprotyas is already working on this.

Since Aug 27, 2021.

  • #142 by @aprotyas — open
backlog bug
Dominant language
EmberScript
Stars
26
Forks
68
Avg merge
2d 13h
Merged PRs (30d)
1

Description

Bug report

Required Info:

  • Operating System:
    • focal
  • Installation type:
    • source
  • Version or commit hash:
    • master
  • DDS implementation:
    • n/a
  • Client library (if applicable):
    • rclpy
Steps to reproduce issue
from test_msgs.msg import UnboundedSequences
msg = UnboundedSequences()
msg.byte_values = b'ffff'
Expected behavior

A bytes instance should be accepted, as it is the type documented in the design doc.

http://design.ros2.org/articles/idl_interface_definition.html

Actual behavior
>>> from test_msgs.msg import UnboundedSequences
>>> msg = UnboundedSequences()
>>> msg.byte_values = msg.byte_values = b'ffff'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sloretz/ws/ros2/install/test_msgs/lib/python3.8/site-packages/test_msgs/msg/_unbounded_sequences.py", line 466, in byte_values
    assert \
AssertionError: The 'byte_values' field must be a set or sequence and each value of type 'bytes'

It only accepts a sequence of bytes instances

msg.byte_values = (b'ff', b'ff')
Additional information

I noticed while reviewing #129

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated setter in /home/sloretz/ws/ros2/install/test_msgs/lib/python3.8/site-packages/test_msgs/msg/_unbounded_sequences.py and compare its byte_values validation with the IDL design document. Reproduce the bytes assignment shown in the issue and verify that a bytes instance is accepted while the existing sequence form remains valid. Pull request #142 is already open, so check its state before starting work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.