Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix python code generation compatibility with Cython
This is a follow-up to protocolbuffers#11011 The generation is still not compatible with Cython when maps are used. For example, this protobuf file: ``` syntax = "proto3"; message Foo { map<string, string> bar = 1; } ``` Will generate: ``` ... _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'a_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None _FOO_BARENTRY._options = None _FOO_BARENTRY._serialized_options = b'8\001' _globals['_FOO']._serialized_start=11 _globals['_FOO']._serialized_end=88 _globals['_FOO_BARENTRY']._serialized_start=46 _globals['_FOO_BARENTRY']._serialized_end=88 ``` The `_FOO_BARENTRY` variable is not defined anywhere and confuses cython. We can see the `_globals` used below, it is simply missing for the first two lines using `_FOO_BARENTRY`.
- Loading branch information