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('R:/Anwendungstechnik/Loepfe 
Projects/Eiger/PS2/Feldtest/India_SarvanaPolytreads/eval_SCHL/demo.py', wdir
='R:/Anwendungstechnik/Loepfe 
Projects/Eiger/PS2/Feldtest/India_SarvanaPolytreads/eval_SCHL')

  File 
"C:\Users\schl\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py"
, line 827, in runfile
    execfile(filename, namespace)

  File 
"C:\Users\schl\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py"
, line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "R:/Anwendungstechnik/Loepfe 
Projects/Eiger/PS2/Feldtest/India_SarvanaPolytreads/eval_SCHL/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/76182a25-cb16-45b1-bc4e-0fc40646c540%40googlegroups.com.

Reply via email to