From 8982d6a823b9fdbfa7dcb53a58d1bb2c3a6a3145 Mon Sep 17 00:00:00 2001 From: Splinter1984 Date: Tue, 22 Jul 2025 13:09:03 +0200 Subject: [PATCH] idl: CDR comp. for unbound seq. & list fix. According to issue #2247, an unbounded sequence and a list of the same subtype have incompatible CDR(v2) as a result of the serialisation operation. By following thought from https://github.com/eclipse-cyclonedds/cyclonedds/issues/2247#issuecomment-3068601131, this commit changes serialisation steps to follow existing sequence ser. process. --- cyclonedds/idl/_builder.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cyclonedds/idl/_builder.py b/cyclonedds/idl/_builder.py index a02ce52..1ee1034 100644 --- a/cyclonedds/idl/_builder.py +++ b/cyclonedds/idl/_builder.py @@ -123,8 +123,16 @@ def _machine_for_type(cls, _type, add_size_header, use_version_2): elif isclass(_type) and (issubclass(_type, IdlBitmask)): return BitMaskMachine(_type, get_idl_annotations(_type)["bit_bound"]) elif get_origin(_type) == list: + submachine = cls._machine_for_type(get_args(_type)[0], add_size_header, use_version_2) + + if isinstance(submachine, PrimitiveMachine): + return PlainCdrV2SequenceOfPrimitiveMachine(submachine.type) + + if isinstance(submachine, (CharMachine)): + add_size_header = False + return SequenceMachine( - cls._machine_for_type(get_args(_type)[0], add_size_header, use_version_2), + submachine, add_size_header=add_size_header ) elif get_origin(_type) == dict: