Skip to content

Commit

Permalink
Escape default arrays and sequences the same other default values
Browse files Browse the repository at this point in the history
Fix #610

Apply the same encode/decode pattern and escaping as for other default values.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
  • Loading branch information
jacobperron committed Oct 14, 2021
1 parent 36ed120 commit 8253770
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rosidl_adapter/rosidl_adapter/msg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def convert_msg_to_idl(package_dir, package_name, input_file, output_dir):

def to_idl_literal(idl_type, value):
if idl_type[-1] == ']' or idl_type.startswith('sequence<'):
content = repr(tuple(value)).replace('\\', r'\\').replace('"', r'\"')
content = repr(tuple(value)).replace('\\', r'\\')
content = content.encode().decode('unicode_escape')
content = content.replace('"', r'\"').replace("'", r"\'")
return f'"{content}"'

if 'boolean' == idl_type:
Expand Down

0 comments on commit 8253770

Please sign in to comment.