Skip to content

Fix compilation of fields named 'bytes' #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

SpencerSharkey
Copy link
Contributor

If you have a bytes field named "bytes", a recursion error occurs when importing the compiled stubs.

if you have a field named "bytes" using the bytes type, it doesn't work.
@Gobot1234
Copy link
Collaborator

Why is bytes a special case, should it not happen for all builtin types?

@nat-n
Copy link
Collaborator

nat-n commented Jan 2, 2021

@SpencerSharkey thanks for doing this.

The solution looks reasonable, however as @Gobot1234 it may be that you've scratched the surface of a larger issue here.

That said it's not immediately obvious to me exactly why this error is happening. I don't have a lot of time to look into this now, but if you could post an (abridged) stack trace of the recursion error then that would help :)

Also it would be good to have a regression test for this, would you be willing to add an example to the test suite following the pattern described here https://github.com/danielgtaylor/python-betterproto/tree/master/tests ?

@nat-n nat-n mentioned this pull request Jan 25, 2021
@Gobot1234
Copy link
Collaborator

Gobot1234 commented Jan 27, 2021

I can't reproduce this

syntax = "proto3";

message Test {
    bytes bytes = 1;  // or string bytes = 1;
}

both compile fine for me. Can you show an example where this doesn't work?

@giantryansaul
Copy link

Commented on the related issue #210, I'm seeing a recursive issue from a definition we have that uses bytes. I tested out this PR locally and it fixed my runtime issue.

@nat-n
Copy link
Collaborator

nat-n commented Apr 5, 2021

@SpencerSharkey Thanks again for your contribution.

I'm closing in favour of #226 because I made some tweaks to extend the fix and enable a test that has already been written to cover it, but didn't have write access to push to the fork (there's a checkbox to allow this when creating the PR).

I hope to have it in a release soon.

@nat-n nat-n closed this Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants