Skip to content

Commit 5b879f1

Browse files
brubbeloroulet
authored andcommitted
fix: Setting LocalizedText.Text attribute does not update Encoding
See #755 This fixes inconsistent Encoding types when performing y=variant_to_binary(x) -> x2=variant_from_binary(y) on auto-generated attributes in the standard address space.
1 parent 0892b5e commit 5b879f1

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

opcua/ua/uatypes.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,24 @@ class LocalizedText(FrozenClass):
517517

518518
def __init__(self, text=None):
519519
self.Encoding = 0
520-
if text is not None and not isinstance(text, str):
521-
raise ValueError("A LocalizedText object takes a string as argument, not a {}, {}".format(text, type(text)))
522-
self.Text = text
523-
if self.Text:
524-
self.Encoding |= (1 << 1)
520+
self._text = None
521+
if text:
522+
self.Text = text
525523
self.Locale = None
526524
self._freeze = True
527525

526+
@property
527+
def Text(self):
528+
return self._text
529+
530+
@Text.setter
531+
def Text(self, text):
532+
if not isinstance(text, str):
533+
raise ValueError("A LocalizedText object takes a string as argument, not a {}, {}".format(type(text), text))
534+
self._text = text
535+
if self._text:
536+
self.Encoding |= (1 << 1)
537+
528538
def to_string(self):
529539
# FIXME: use local
530540
if self.Text is None:

0 commit comments

Comments
 (0)