Exception while using annotation hashid
When I use hash annotations to modify the dataclass field, I throw an exception: TypeError: Strings must be encoded before hashing My dataclass is: @dataclass class PersonHashid(idl.IdlStruct, typename="PersonHashid"): name: str annotate.member_hash_id("name", "123") age: types.int32 address: str
An exception occurred when I used the following code to initialize the topic : participant = DomainParticipant(0) topic = Topic(participant,"HelloWorldTopic", PersonHashid)
Abnormal information: mid = unpack("<I", md5(f_annot.get("hash_id", "") or name.encode()).digest()[:4])[0] & 0x0FFFFFFF ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Strings must be encoded before hashing
After tracking the code, it was found that the problem occurred in the file cyclonedds/idl/_main. py: mid=unpack ("<I", md5 (f-annot. get ("hash_id", "") or name. encode()). digest() [: 4]) [0]&0x0FFFFFFF
Is the correct code supposed to be: mid=unpack ("<I", md5 ((f-annot. get ("hash_id", "") or name). encode()). digest() [: 4]) [0]&0x0FFFFFFF ?