mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-19 11:36:41 +00:00
Fix empty strings not working as expected for flag parameters
This commit is contained in:
parent
fb9813ae61
commit
9c66f0b2b4
@ -464,9 +464,11 @@ class TLGenerator:
|
|||||||
# Vector flags are special since they consist of 3 values,
|
# Vector flags are special since they consist of 3 values,
|
||||||
# so we need an extra join here. Note that empty vector flags
|
# so we need an extra join here. Note that empty vector flags
|
||||||
# should NOT be sent either!
|
# should NOT be sent either!
|
||||||
builder.write("b'' if not {} else b''.join((".format(name))
|
builder.write("b'' if {0} is None or {0} is False "
|
||||||
|
"else b''.join((".format(name))
|
||||||
else:
|
else:
|
||||||
builder.write("b'' if not {} else (".format(name))
|
builder.write("b'' if {0} is None or {0} is False "
|
||||||
|
"else (".format(name))
|
||||||
|
|
||||||
if arg.is_vector:
|
if arg.is_vector:
|
||||||
if arg.use_vector_id:
|
if arg.use_vector_id:
|
||||||
@ -495,11 +497,14 @@ class TLGenerator:
|
|||||||
# 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:
|
||||||
builder.write("struct.pack('<I', {})".format(
|
builder.write("struct.pack('<I', ")
|
||||||
' | '.join('({} if {} else 0)'.format(
|
builder.write(
|
||||||
1 << flag.flag_index, 'self.{}'.format(flag.name)
|
' | '.join('(0 if {0} is None or {0} is False else {1})'
|
||||||
) for flag in args if flag.is_flag)
|
.format('self.{}'.format(flag.name),
|
||||||
))
|
1 << flag.flag_index)
|
||||||
|
for flag in args if flag.is_flag)
|
||||||
|
)
|
||||||
|
builder.write(')')
|
||||||
|
|
||||||
elif 'int' == arg.type:
|
elif 'int' == arg.type:
|
||||||
# struct.pack is around 4 times faster than int.to_bytes
|
# struct.pack is around 4 times faster than int.to_bytes
|
||||||
|
Loading…
Reference in New Issue
Block a user