flatbuffers
flatbuffers copied to clipboard
Flatbuffer python generation failed when nested flatbuffers are used within a child namespace
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 https://github.com/google/flatbuffers/blob/1c514626e83c20fffa8557e75641848e1e15cd5e/src/idl_gen_python.cpp#L1115 to
const std::string unqualified_name = namer_.Type(struct_def);
in order to get the correct naming for import
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.
This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.