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
I get:
0
0
label: "foo"
text_span {
start_char_offset: 0
}
so it is getting set but not staying set unless I use some oneof magic.
It seems things are going south python_message.py field_setter(self, new_value) when new_value = 0
In particular this if statement is true when new_value is zero:
if clear_when_set_to_default and not new_value:
self._fields.pop(field, None)
After having read this and "Also note that if a scalar message field is set to its default, the value will not be serialized on the wire." in the defaults documentation this may actually be desired behavior. However, this is confusing as all get out. Seemingly defaults are there to be relied on? However, in my case the field was actually being set to zero (not defaulting to zero) but acts as if that field was never set! Oh man, I chased my tail on this one.
The text was updated successfully, but these errors were encountered:
Using protobuf release 3.0.0b3 and b2.
I built up this example to demonstrate.
document_markup.proto
When I run this python code:
I get:
0
0
label: "foo"
text_span {
start_char_offset: 0
}
so it is getting set but not staying set unless I use some oneof magic.
It seems things are going south python_message.py field_setter(self, new_value) when new_value = 0
In particular this if statement is true when new_value is zero:
if clear_when_set_to_default and not new_value:
self._fields.pop(field, None)
After having read this and "Also note that if a scalar message field is set to its default, the value will not be serialized on the wire." in the defaults documentation this may actually be desired behavior. However, this is confusing as all get out. Seemingly defaults are there to be relied on? However, in my case the field was actually being set to zero (not defaulting to zero) but acts as if that field was never set! Oh man, I chased my tail on this one.
The text was updated successfully, but these errors were encountered: