* Fix issue #4389, if field is ommitted the return type is the same for python generator * Fix issue #4389, bytes is returned when field is omitted * Fix issue #4389, added generated python code after generator modification
This commit is contained in:
parent
971a68110e
commit
5e4739184f
|
@ -198,7 +198,7 @@ static void GetStringField(const StructDef &struct_def,
|
|||
code += OffsetPrefix(field);
|
||||
code += Indent + Indent + Indent + "return " + GenGetter(field.value.type);
|
||||
code += "o + self._tab.Pos)\n";
|
||||
code += Indent + Indent + "return \"\"\n\n";
|
||||
code += Indent + Indent + "return bytes()\n\n";
|
||||
}
|
||||
|
||||
// Get the value of a union from an object.
|
||||
|
|
|
@ -49,7 +49,7 @@ class Monster(object):
|
|||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return ""
|
||||
return bytes()
|
||||
|
||||
# Monster
|
||||
def Inventory(self, j):
|
||||
|
|
|
@ -23,7 +23,7 @@ class Stat(object):
|
|||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return ""
|
||||
return bytes()
|
||||
|
||||
# Stat
|
||||
def Val(self):
|
||||
|
|
|
@ -895,7 +895,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
|
|||
self.assertEqual(100, self.mon.Hp())
|
||||
|
||||
def test_default_monster_name(self):
|
||||
self.assertEqual('', self.mon.Name())
|
||||
self.assertEqual(b'', self.mon.Name())
|
||||
|
||||
def test_default_monster_inventory_item(self):
|
||||
self.assertEqual(0, self.mon.Inventory(0))
|
||||
|
|
Loading…
Reference in New Issue