Merge branch 'master' into asyncio

This commit is contained in:
Lonami Exo
2017-10-16 10:03:01 +02:00
17 changed files with 450 additions and 245 deletions

View File

@@ -129,13 +129,10 @@ class BinaryReader:
return False
# If there was still no luck, give up
self.seek(-4) # Go back
raise TypeNotFoundError(constructor_id)
# Create an empty instance of the class and
# fill it with the read attributes
result = clazz.empty()
result.on_response(self)
return result
return clazz.from_reader(self)
def tgread_vector(self):
"""Reads a vector (a list) of Telegram objects"""

View File

@@ -15,7 +15,7 @@ class TcpClient:
if isinstance(timeout, timedelta):
self.timeout = timeout.seconds
elif isinstance(timeout, int) or isinstance(timeout, float):
elif isinstance(timeout, (int, float)):
self.timeout = float(timeout)
else:
raise ValueError('Invalid timeout type', type(timeout))