@@ -106,7 +106,12 @@ def add_attribute(self, attribute, value): # type (attribute: str, value: typin
106
106
:param str attribute: Attribute name
107
107
:param any value: Attribute value
108
108
"""
109
- self .attributes [attribute ] = value
109
+ try :
110
+ self .attributes [attribute ] = str (value )
111
+ except UnicodeDecodeError :
112
+ self .attributes [attribute ] = value
113
+ if type (self .attributes [attribute ]) == str :
114
+ self .attributes [attribute ] = self .attributes [attribute ].strip ()
110
115
111
116
def del_attribute (self , attribute ):
112
117
if attribute in self .attributes :
@@ -282,7 +287,12 @@ def add_attribute(self, attribute, value):
282
287
:param str attribute: attribute name
283
288
:param value: attribute value
284
289
"""
285
- self .attributes [attribute ] = value
290
+ try :
291
+ self .attributes [attribute ] = str (value )
292
+ except UnicodeDecodeError :
293
+ self .attributes [attribute ] = value
294
+ if type (self .attributes [attribute ]) == str :
295
+ self .attributes [attribute ] = self .attributes [attribute ].strip ()
286
296
287
297
def del_attribute (self , attribute ):
288
298
"""
@@ -1715,7 +1725,12 @@ def add_attribute(self, attribute, value): # type: (str, typing.Any) -> None
1715
1725
:param str attribute: attribute name
1716
1726
:param value: attribute value
1717
1727
"""
1718
- self .attributes [attribute ] = value
1728
+ try :
1729
+ self .attributes [attribute ] = str (value )
1730
+ except UnicodeDecodeError :
1731
+ self .attributes [attribute ] = value
1732
+ if type (self .attributes [attribute ]) == str :
1733
+ self .attributes [attribute ] = self .attributes [attribute ].strip ()
1719
1734
1720
1735
def add_signal_defines (self , type , definition ):
1721
1736
"""
0 commit comments