Skip to content

Commit a6299f8

Browse files
committed
Use a proper condition check when dealing with flag vectors
When reading flag vectors, non-existent vectors are being translated to [] (empty list). When writing them, the flag condition was strictly checking for None and an empty list [] would result in an empty vector being serialized, which should not happen. Related to #871.
1 parent db9489b commit a6299f8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

compiler/api/compiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def start(format: bool = False):
408408
flag = FLAGS_RE_2.match(i[1])
409409

410410
if flag:
411-
if flag.group(2) == "true":
411+
if flag.group(2) == "true" or flag.group(2).startswith("Vector"):
412412
write_flags.append(f"flags |= (1 << {flag.group(1)}) if self.{i[0]} else 0")
413413
else:
414414
write_flags.append(f"flags |= (1 << {flag.group(1)}) if self.{i[0]} is not None else 0")
@@ -441,7 +441,7 @@ def start(format: bool = False):
441441
sub_type = arg_type.split("<")[1][:-1]
442442

443443
write_types += "\n "
444-
write_types += f"if self.{arg_name} is not None:\n "
444+
write_types += f"if self.{arg_name}:\n "
445445
write_types += "b.write(Vector(self.{}{}))\n ".format(
446446
arg_name, f", {sub_type.title()}" if sub_type in CORE_TYPES else ""
447447
)

0 commit comments

Comments
 (0)