Python --gen-onefile option not respecting include directive
Found in Version: flatc version 24.12.23
Steps to Reproduce:
- Build the following
.fbsfiles:
inc.fbs:
table Foo {
bar:int;
baz:float;
}
base.fbs:
include "inc.fbs";
table Message {
payload:Foo;
}
root_type Message;
- Run
flatc --python --gen-onefile --gen-object-api -I ./ inc.fbs base.fbs
- Note that
--gen-object-apiisn't the broken flag -importerrors can still be seen without it, it's just useful for demonstration purposes
- Deserialize a populated
MessageTobject:
from base_generated import MessageT
from inc_generated import FooT
import flatbuffers
payload = FooT()
payload.bar = 42
payload.baz = 12.3
msg = MessageT()
msg.payload = payload
builder = flatbuffers.Builder(0)
builder.Finish(msg.Pack(builder))
MessageT().InitFromPackedBuf(builder.Output())
Expected Behavior
Deserializing a MessageT object is supported
Actual Behavior
Deserializing the MessageT object throws a NameError because Foo is not defined (not imported from inc_generated.py) in Message.Payload().
@lu-wang-g , it looks like you're the primary maintainer for the Python side of this utility. Is one of the (known?) ramifications of --gen-onefile that include directives are not allowed in FBS files? If so, can the documentation be updated to reflect that requirement?
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.