summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDariusz Ostolski <dariusz.ostolski@gmail.com>2017-10-05 23:07:42 +0200
committerWouter van Oortmerssen <aardappel@gmail.com>2017-10-05 14:07:42 -0700
commit5e4739184f7ac028dfe2eb14eed5c3e25b49f9c9 (patch)
tree6dee6c2eb6ace4dc492a362ce3f5dc1f5cb10658
parent971a68110e4fc1bace10fcb6deeb189e7e1a34ce (diff)
downloadflatbuffers-5e4739184f7ac028dfe2eb14eed5c3e25b49f9c9.tar.gz
flatbuffers-5e4739184f7ac028dfe2eb14eed5c3e25b49f9c9.tar.bz2
flatbuffers-5e4739184f7ac028dfe2eb14eed5c3e25b49f9c9.zip
Fix issue #4389, if field is ommitted the return type is the same for… (#4444)
* 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
-rw-r--r--src/idl_gen_python.cpp2
-rw-r--r--tests/MyGame/Example/Monster.py2
-rw-r--r--tests/MyGame/Example/Stat.py2
-rw-r--r--tests/py_test.py2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/idl_gen_python.cpp b/src/idl_gen_python.cpp
index fd2e1c3f..a1a96b5c 100644
--- a/src/idl_gen_python.cpp
+++ b/src/idl_gen_python.cpp
@@ -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.
diff --git a/tests/MyGame/Example/Monster.py b/tests/MyGame/Example/Monster.py
index 910f39ab..fc834edb 100644
--- a/tests/MyGame/Example/Monster.py
+++ b/tests/MyGame/Example/Monster.py
@@ -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):
diff --git a/tests/MyGame/Example/Stat.py b/tests/MyGame/Example/Stat.py
index b0e251d4..2e0cc05c 100644
--- a/tests/MyGame/Example/Stat.py
+++ b/tests/MyGame/Example/Stat.py
@@ -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):
diff --git a/tests/py_test.py b/tests/py_test.py
index d15a3165..1302722b 100644
--- a/tests/py_test.py
+++ b/tests/py_test.py
@@ -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))