From 49e1ea3335e3b08787ec7ea454a484cb6b942d3a Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Mon, 13 Jun 2022 09:16:00 -0400 Subject: 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 --- python/flatbuffers/builder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'python') 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) -- cgit v1.2.3