summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorCaleb Zulawski <caleb.zulawski@gmail.com>2022-06-13 09:16:00 -0400
committerGitHub <noreply@github.com>2022-06-13 09:16:00 -0400
commit49e1ea3335e3b08787ec7ea454a484cb6b942d3a (patch)
tree29c4578d359d032383eaee5ab34fae90b3046cde /python
parent11a19887053534c43f73e74786b46a615ecbf28e (diff)
downloadflatbuffers-49e1ea3335e3b08787ec7ea454a484cb6b942d3a.tar.gz
flatbuffers-49e1ea3335e3b08787ec7ea454a484cb6b942d3a.tar.bz2
flatbuffers-49e1ea3335e3b08787ec7ea454a484cb6b942d3a.zip
Implement optional scalars for Python (#7318)
* Implement optional scalars for Python * Use == for integer comparison, remove empty line * Fix optional type hint Co-authored-by: Caleb Zulawski <caleb.zulawski@caci.com>
Diffstat (limited to 'python')
-rw-r--r--python/flatbuffers/builder.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/python/flatbuffers/builder.py b/python/flatbuffers/builder.py
index 02358d6d..9bdf116c 100644
--- a/python/flatbuffers/builder.py
+++ b/python/flatbuffers/builder.py
@@ -578,9 +578,11 @@ class Builder(object):
self.Place(off, flags)
def PrependSlot(self, flags, o, x, d):
- N.enforce_number(x, flags)
- N.enforce_number(d, flags)
- if x != d or self.forceDefaults:
+ if x is not None:
+ N.enforce_number(x, flags)
+ if d is not None:
+ N.enforce_number(d, flags)
+ if x != d or (self.forceDefaults and d is not None):
self.Prepend(flags, x)
self.Slot(o)