Skip to content

Flatbuffer python generation failed when nested flatbuffers are used within a child namespace #8554

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

Open
hotwinter opened this issue Mar 11, 2025 · 0 comments

Comments

@hotwinter
Copy link

Define the following files

namespace test_nested.nested;

file_identifier "TESB";

table B {
  data1:[ubyte];
}

root_type B;
include "B.fbs";
namespace test_nested;

file_identifier "TESA";

table A {
  data2:[ubyte] (force_align: 64, nested_flatbuffer:"nested.B");
}

root_type A;

and generate the python code using flatc --python A.fbs

try including the generated file in a python file errors out when executing

from test_nested import A as a_fbs
Traceback (most recent call last):
    from test_nested.nested.B import nested.B
                                           ^
SyntaxError: invalid syntax

The solution is to change the line in

const std::string unqualified_name = nested->constant;
to

const std::string unqualified_name = namer_.Type(struct_def);

in order to get the correct naming for import

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

No branches or pull requests

1 participant