mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Fixed JSON encoding and decoding for lists, added empty() method
The new empty() method retrieves an empty instance of the given object, with all the attributes set to None
This commit is contained in:
@@ -117,14 +117,8 @@ class BinaryReader:
|
||||
# If there was still no luck, give up
|
||||
raise TypeNotFoundError(constructor_id)
|
||||
|
||||
# Now we need to determine the number of parameters of the class, so we can
|
||||
# instantiate it with all of them set to None, and still, no need to write
|
||||
# the default =None in all the classes, thus forcing the user to provide a real value
|
||||
sig = inspect.signature(clazz.__init__)
|
||||
params = [None] * (len(sig.parameters) - 1) # Subtract 1 (self)
|
||||
result = clazz(*params) # https://docs.python.org/3/tutorial/controlflow.html#unpacking-argument-lists
|
||||
|
||||
# Finally, read the object and return the result
|
||||
# Create an empty instance of the class, and read its values
|
||||
result = clazz.empty()
|
||||
result.on_response(self)
|
||||
return result
|
||||
|
||||
|
Reference in New Issue
Block a user