Hi,

I am facing a problem with oneof {} inside a nested message and Python 3.7 
(not sure whether it is limited to Python 3.7 or even to Python in 
general). Example:

*demo.proto*
syntax = "proto3";

package oneofInsideNestedMessage;

message outside {
    message inside {
        oneof dummyName {
                MsgA a = 1;
                MsgB b = 2;
        }
    }
}

message MsgA {
        string text = 1;
}

message MsgB {
        uint32 number = 1;
}


*demo.py:*
from demo_pb2 import outside

msg = outside()
msg.inside.a.text = 'test'

*Result:*

I expect that this will

a) choose MsgA as type for the oneof {
b) set text field to 'test'

What actually happens:

Traceback (most recent call last):

  File "<ipython-input-6-da73825bef90>", line 1, in <module>
    runfile('.../demo.py', wdir='...')

  File "...\site-packages\spyder_kernels\customize\spydercustomize.py", 
line 827, in runfile
    execfile(filename, namespace)

  File "...\site-packages\spyder_kernels\customize\spydercustomize.py", 
line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File ".../demo.py", line 11, in <module>
    msg.inside.a.text = 'test'

AttributeError: '_FieldProperty' object has no attribute 'text'

It does *not *happen when oneof is located in "outside" only when in 
"inside". As I want to switch an existing format to protobuf I do not want 
to change the structure of the data as this would break existing 
application code. Is this considered a bug (i.e., will go away eventually) 
or is this a limitation that will remain?

Best regards and thanks for making protobuf available publicly,
Adrian

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/d635e3b5-a8c0-43b6-bc4d-13958539e682%40googlegroups.com.

Reply via email to