mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 18:46:40 +00:00
Don't treat False field as flag omission
8724949b54
was only half the story.
This commit is contained in:
parent
58013f4f44
commit
b06f496a27
@ -459,12 +459,16 @@ def _write_arg_to_bytes(builder, arg, tlobject, name=None):
|
|||||||
# There's a flag indicator, but no flag arguments so it's 0
|
# There's a flag indicator, but no flag arguments so it's 0
|
||||||
builder.write(r"b'\0\0\0\0'")
|
builder.write(r"b'\0\0\0\0'")
|
||||||
else:
|
else:
|
||||||
|
def fmt_flag(flag):
|
||||||
|
if flag.type == 'Bool':
|
||||||
|
fmt = '(0 if {0} is None else {1})'
|
||||||
|
else:
|
||||||
|
fmt = '(0 if {0} is None or {0} is False else {1})'
|
||||||
|
return fmt.format('self.{}'.format(flag.name), 1 << flag.flag_index)
|
||||||
|
|
||||||
builder.write("struct.pack('<I', ")
|
builder.write("struct.pack('<I', ")
|
||||||
builder.write(
|
builder.write(
|
||||||
' | '.join('(0 if {0} is None or {0} is False else {1})'
|
' | '.join(fmt_flag(flag) for flag in tlobject.args if flag.is_flag)
|
||||||
.format('self.{}'.format(flag.name),
|
|
||||||
1 << flag.flag_index)
|
|
||||||
for flag in tlobject.args if flag.is_flag)
|
|
||||||
)
|
)
|
||||||
builder.write(')')
|
builder.write(')')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user