Skip to content

[Python] Fix FlexBuffers typed vector float conversion - #9181

Open
winklemad wants to merge 1 commit into
google:masterfrom
winklemad:fix-python-flexbuffers-as-float
Open

[Python] Fix FlexBuffers typed vector float conversion#9181
winklemad wants to merge 1 commit into
google:masterfrom
winklemad:fix-python-flexbuffers-as-float

Conversation

@winklemad

Copy link
Copy Markdown

Summary

  • Fix Ref.AsFloat for typed and fixed typed vectors by treating their type checks as properties.
  • Use AsFixedTypedVector when reading fixed typed-vector length.
  • Add regression coverage through the public Builder, Finish, and GetRoot APIs.

Problem

IsTypedVector and IsFixedTypedVector are properties, but AsFloat called them as functions. Valid typed vectors therefore raised TypeError. The fixed-vector branch also referenced the nonexistent FixedTypedVector accessor.

Testing

  • PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=python python3 -m unittest tests.py_flexbuffers_test.DecoderTest.test_typed_vectors_as_float
  • PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=../python python3 py_flexbuffers_test.py
  • Both generated-code modes of py_test.py — 127 tests passed each.
  • git diff --check

The wrapper suites tests/PythonTest.sh and tests/TestAll.sh, which require CMake and a built flatc for their Python stage, were not run locally. The relevant Python runtime suites were run directly.

Ref.AsFloat called IsTypedVector()/IsFixedTypedVector() as methods, but
they are properties, so it raised TypeError: 'bool' object is not callable
on any typed or fixed typed vector. It also referenced the non-existent
FixedTypedVector attribute instead of AsFixedTypedVector.
@winklemad
winklemad force-pushed the fix-python-flexbuffers-as-float branch from 709f6a6 to c8674ce Compare August 23, 2026 16:37
@winklemad

Copy link
Copy Markdown
Author

Rebased onto current master to clear the stale merge base — CI is green and there are no conflicts now.

Quick recap for whoever picks this up: Ref.AsFloat calls IsTypedVector() and IsFixedTypedVector() as methods, but both are @property, so AsFloat raises TypeError: 'bool' object is not callable on any typed or fixed typed vector. It also references a non-existent FixedTypedVector attribute instead of AsFixedTypedVector. The change is two source lines plus a regression test that fails on master (the TypeError) and passes with the fix; the full py_flexbuffers_test.py suite stays green (61 passed).

Happy to adjust anything if you'd like it shaped differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant