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.
This commit is contained in:
parent
db9489b318
commit
a6299f8401
@ -408,7 +408,7 @@ def start(format: bool = False):
|
||||
flag = FLAGS_RE_2.match(i[1])
|
||||
|
||||
if flag:
|
||||
if flag.group(2) == "true":
|
||||
if flag.group(2) == "true" or flag.group(2).startswith("Vector"):
|
||||
write_flags.append(f"flags |= (1 << {flag.group(1)}) if self.{i[0]} else 0")
|
||||
else:
|
||||
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):
|
||||
sub_type = arg_type.split("<")[1][:-1]
|
||||
|
||||
write_types += "\n "
|
||||
write_types += f"if self.{arg_name} is not None:\n "
|
||||
write_types += f"if self.{arg_name}:\n "
|
||||
write_types += "b.write(Vector(self.{}{}))\n ".format(
|
||||
arg_name, f", {sub_type.title()}" if sub_type in CORE_TYPES else ""
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user