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>
This commit is contained in:
Caleb Zulawski
2022-06-13 09:16:00 -04:00
committed by GitHub
parent 11a1988705
commit 49e1ea3335
8 changed files with 594 additions and 10 deletions

View File

@@ -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)