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
Parsing FlatBuffers with Python in 22.9.24 is broken #7569
Comments
Oh also, smells like the tests for nested tables needs to be fixed to deal catch this case. |
Hey folks, 22.9.24 is still the latest on pypi and it's broken. Any chance someone (@dbaileychess @rw @aardappel) could build and publish a release? |
…7576) * feat: Fixed the issue with nested unions relying on InitFromBuf. Problem: Issue #7569 Nested Unions were broken with the introduction of parsing buffers with an initial encoding offset. Fix: Revert the InitFromBuf method to the previous version and introduction of InitFromPackedBuf that allows users to read types from packed buffers applying the offset automatically. Test: Added in TestNestedUnionTables to test the encoding and decoding ability using a nested table with a union field. * fix: Uncommented generate code command
@stewartmiles Sorry for the delay, I just merged the fix. I am trying to automate publishing to our package managers (including Pypi) on releases, do you mind if I take a bit to set this up before releasing again with this fix in? |
@dbaileychess no worries, we're all good we just pinned to the previous release of FlatBuffers. I'm primarily concerned about newcomers to the project who will pull the latest from pypi and have a broken experience. Is it possible to publish the previous version as a new version manually to at least unbreak head on pypi? |
If it's a pain, I get it .. just folks will likely have a bad experience and not join the cult of "Flat" :) |
Should be up now: https://pypi.org/project/flatbuffers/22.10.26/ |
Sweet thanks @dbaileychess 😄 |
Python's code generator was broken by #7529 (FYI @joshua-smith8).
Given the table
Foo
, when generating code for the object APIFooT
now skips flatbuffer file headers.For example, before pull/7529,
tests/monster_test_generated.py
:flatbuffers/tests/monster_test_generated.py
Lines 177 to 181 in 2ad4086
After:
flatbuffers/tests/monster_test_generated.py
Lines 178 to 183 in c92e78a
This is cool as
FooT.InitFromBuf()
interprets thebuf
argument in the same way asFoo.GetRootAs()
, i.e it assumesbuf
points at the start of a packed flatbuffer file and skips the header. However, this has some issues as:foo = FooT.InitFromObj(Foo.GetRootAs(buf))
.InitFromObj
is used to parse nested union tables which is broken as they end up skipping the header block:flatbuffers/tests/monster_test_generated.py
Lines 38 to 48 in c92e78a
Since
FooT.InitFromBuf()
is now better? since it aligns withGetRootAs()
perhaps the solution is to extendInitFromBuf()
to support parsing nested tables?The text was updated successfully, but these errors were encountered: