fix python code generation compatibility with Cython#13593
fix python code generation compatibility with Cython#13593vthib wants to merge 1 commit intoprotocolbuffers:mainfrom
Conversation
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`.
|
Thank you for the PR. As it changes generated code, I may need to run a wide tests in google internal and submit there |
copied from #13593 PiperOrigin-RevId: 560774287
|
Turns out tests can not pass. Example error: I will update the fix |
raised by #13593 PiperOrigin-RevId: 560774287
raised by #13593 PiperOrigin-RevId: 560774287
raised by #13593 PiperOrigin-RevId: 561077681
|
should be fixed with e65d051 |
|
Thanks! |
|
@anandolee Is it possible to backport this fix into the next 24.X release? |
|
@anandolee Sorry for the bother, I saw the new release 24.3 release but it does not contain this fix. Is it possible to backport it for the next 24.X release please? |
|
@anandolee Can I do a PR to backport this fix into the 24.X branch? |
|
I pushed a PR request for the backport here: #14240 |
raised by protocolbuffers#13593 PiperOrigin-RevId: 561077681
|
|
|
This is a follow-up to #11011
The generation is still not compatible with Cython when maps are used.
For example, this protobuf file:
Will generate:
The
_FOO_BARENTRYvariable is not defined anywhere and confuses cython. We can see the_globalsused below, it is simply missing for the first two lines using_FOO_BARENTRY.If possible, i would love to have this fix in the next 24 release, instead of having to wait for the 25 release.