mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-10-31 16:07:44 +03: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, | ||||
|                 # so we need an extra join here. Note that empty vector flags | ||||
|                 # 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: | ||||
|                 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.use_vector_id: | ||||
|  | @ -495,11 +497,14 @@ class TLGenerator: | |||
|                 # There's a flag indicator, but no flag arguments so it's 0 | ||||
|                 builder.write(r"b'\0\0\0\0'") | ||||
|             else: | ||||
|                 builder.write("struct.pack('<I', {})".format( | ||||
|                     ' | '.join('({} if {} else 0)'.format( | ||||
|                         1 << flag.flag_index, 'self.{}'.format(flag.name) | ||||
|                     ) for flag in args if flag.is_flag) | ||||
|                 )) | ||||
|                 builder.write("struct.pack('<I', ") | ||||
|                 builder.write( | ||||
|                     ' | '.join('(0 if {0} is None or {0} is False else {1})' | ||||
|                                .format('self.{}'.format(flag.name), | ||||
|                                        1 << flag.flag_index) | ||||
|                                for flag in args if flag.is_flag) | ||||
|                 ) | ||||
|                 builder.write(')') | ||||
| 
 | ||||
|         elif 'int' == arg.type: | ||||
|             # struct.pack is around 4 times faster than int.to_bytes | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user