You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ?
The text was updated successfully, but these errors were encountered:
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 ?
The text was updated successfully, but these errors were encountered: