From bb0d29bdd52fb5bd6e0d4556676133a42f68c43c Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 22 May 2018 19:21:01 +0200 Subject: [PATCH] Fix unboxed serialization including constructor ID This only affected FutureSalts, but it's useful that it behaves the way it should. cc @JuanPotato for spotting the bug. --- telethon_generator/generators/tlobject.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/telethon_generator/generators/tlobject.py b/telethon_generator/generators/tlobject.py index 36d1f013..1058a1ae 100644 --- a/telethon_generator/generators/tlobject.py +++ b/telethon_generator/generators/tlobject.py @@ -466,6 +466,12 @@ def _write_arg_to_bytes(builder, arg, args, name=None): # Else it may be a custom type builder.write('bytes({})', name) + # If the type is not boxed (i.e. starts with lowercase) we should + # not serialize the constructor ID (so remove its first 4 bytes). + boxed = arg.type[arg.type.find('.') + 1].isupper() + if not boxed: + builder.write('[4:]') + if arg.is_flag: builder.write(')') if arg.is_vector: