Skip to content

[Python] Fix FlexBuffers Ref.IsAnyVector raising TypeError - #9279

Open
kwy404 wants to merge 1 commit into
google:masterfrom
kwy404:fix-python-flexbuffers-is-any-vector
Open

kwy404 wants to merge 1 commit into
google:masterfrom
kwy404:fix-python-flexbuffers-is-any-vector

Conversation

@kwy404

@kwy404 kwy404 commented Sep 26, 2026

Copy link
Copy Markdown

Root cause: Ref.IsFixedTypedVector is a property, but Ref.IsAnyVector calls it as a function (self.IsFixedTypedVector()). Any value that is not a vector, map or typed vector reaches that call, so IsAnyVector raises TypeError: 'bool' object is not callable instead of returning a bool. That includes ints, floats, strings, blobs, null and fixed typed vectors.

from flatbuffers import flexbuffers
flexbuffers.GetRoot(flexbuffers.Dumps(1)).IsAnyVector  # TypeError

Fix: drop the parentheses so the property is read like the other two checks on the same line.

Test: _check_int now asserts IsAnyVector is False and _check_fixed_typed_vector asserts it is True. Before the fix, python py_flexbuffers_test.py fails with 560 subtest errors in test_int, test_indirect_int, test_uint, test_inidirect_uint, test_fixed_typed_vector_int and test_fixed_typed_vector_uint, all with the TypeError above. After the fix all 60 tests pass.

This is the same mistake that #9181 fixes in AsFloat; that PR does not touch IsAnyVector.

IsFixedTypedVector is a property, but IsAnyVector called it as a
function. Any value that is not a vector, map or typed vector reached
that call and raised "TypeError: 'bool' object is not callable".

This branch has not been deployed

No deployments
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