mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Fix parsing for constructors and not objects (#348)
This commit is contained in:
@@ -5,7 +5,7 @@ import struct
|
||||
from zlib import crc32
|
||||
from collections import defaultdict
|
||||
|
||||
from .parser import SourceBuilder, TLParser
|
||||
from .parser import SourceBuilder, TLParser, TLObject
|
||||
AUTO_GEN_NOTICE = \
|
||||
'"""File generated by TLObjects\' generator. All changes will be ERASED"""'
|
||||
|
||||
@@ -129,6 +129,9 @@ class TLGenerator:
|
||||
builder.writeln(
|
||||
'from {}.tl.tlobject import TLObject'.format('.' * depth)
|
||||
)
|
||||
builder.writeln(
|
||||
'from {}.tl import types'.format('.' * depth)
|
||||
)
|
||||
|
||||
# Add the relative imports to the namespaces,
|
||||
# unless we already are in a namespace.
|
||||
@@ -638,7 +641,11 @@ class TLGenerator:
|
||||
|
||||
else:
|
||||
# Else it may be a custom type
|
||||
builder.writeln('{} = reader.tgread_object()'.format(name))
|
||||
if not arg.skip_constructor_id:
|
||||
builder.writeln('{} = reader.tgread_object()'.format(name))
|
||||
else:
|
||||
builder.writeln('{} = types.{}.from_reader(reader)'.format(
|
||||
name, TLObject.class_name_for(arg.type)))
|
||||
|
||||
# End vector and flag blocks if required (if we opened them before)
|
||||
if arg.is_vector:
|
||||
|
Reference in New Issue
Block a user