flatbuffers
flatbuffers copied to clipboard
[Python] Object API breaks for structs will all-caps names
Affected Language: Python Compiler Version: flatc version 23.5.26 Operating System: Windows 10
fbs file (test.fbs)
struct ALLCAPS
{
data : uint8;
}
Compiler command line
flatc --python --gen-object-api test.fbs
Issue
In the generated Python code, the object API uses the wrong function name to create the 'ALLCAPS' struct in the Pack()
call.
Function to create the ALLCAPS structure:
def CreateALLCAPS(builder, data):
builder.Prep(1, 1)
builder.PrependUint8(data)
return builder.Offset()
Generated Object API:
class ALLCAPST(object):
...
# ALLCAPST
def Pack(self, builder):
return CreateAllcaps(builder, self.data)
Regardless of ones stance about whether or not name-mangling should be applied to ensure uniform camel/snake case, the generated code should be self-consistent.
Either
-
def CreateALLCAPS(builder, data):
should bedef CreateAllcaps(builder, data):
, or -
return CreateAllcaps(builder, self.data)
should bereturn CreateALLCAPS(builder, self.data)