Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
b10123ff
Commit
b10123ff
authored
May 10, 2018
by
Tin Tvrtković
Committed by
Wouter van Oortmerssen
May 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python: return None for missing strings. (#4733)
[BREAKING CHANGE] Python: return None for missing strings.
parent
3a2c5355
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
4 deletions
+4
-4
idl_gen_python.cpp
src/idl_gen_python.cpp
+1
-1
Monster.py
tests/MyGame/Example/Monster.py
+1
-1
Stat.py
tests/MyGame/Example/Stat.py
+1
-1
py_test.py
tests/py_test.py
+1
-1
No files found.
src/idl_gen_python.cpp
View file @
b10123ff
...
...
@@ -194,7 +194,7 @@ static void GetStringField(const StructDef &struct_def, const FieldDef &field,
code
+=
OffsetPrefix
(
field
);
code
+=
Indent
+
Indent
+
Indent
+
"return "
+
GenGetter
(
field
.
value
.
type
);
code
+=
"o + self._tab.Pos)
\n
"
;
code
+=
Indent
+
Indent
+
"return
bytes()
\n\n
"
;
code
+=
Indent
+
Indent
+
"return
None
\n\n
"
;
}
// Get the value of a union from an object.
...
...
tests/MyGame/Example/Monster.py
View file @
b10123ff
...
...
@@ -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
bytes
()
return
None
# Monster
def
Inventory
(
self
,
j
):
...
...
tests/MyGame/Example/Stat.py
View file @
b10123ff
...
...
@@ -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
bytes
()
return
None
# Stat
def
Val
(
self
):
...
...
tests/py_test.py
View file @
b10123ff
...
...
@@ -917,7 +917,7 @@ class TestAllCodePathsOfExampleSchema(unittest.TestCase):
self
.
assertEqual
(
100
,
self
.
mon
.
Hp
())
def
test_default_monster_name
(
self
):
self
.
assertEqual
(
b
''
,
self
.
mon
.
Name
())
self
.
assertEqual
(
None
,
self
.
mon
.
Name
())
def
test_default_monster_inventory_item
(
self
):
self
.
assertEqual
(
0
,
self
.
mon
.
Inventory
(
0
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment