mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-04 04:00:18 +03:00
Fixing python 3.4 compatibility support. Possible issue with circular imports (https://docs.python.org/3/whatsnew/3.5.html#other-language-changes) which is handled ok it 3.5+ and is giving an error in 3.4
This commit is contained in:
parent
050cd95d32
commit
8da6ffd7d5
|
@ -1,7 +1,7 @@
|
||||||
import struct
|
import struct
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
|
||||||
from .. import helpers as utils
|
from ..helpers import calc_msg_key
|
||||||
from ..extensions import BinaryReader
|
from ..extensions import BinaryReader
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,4 +20,4 @@ class AuthKey:
|
||||||
"""
|
"""
|
||||||
new_nonce = new_nonce.to_bytes(32, 'little', signed=True)
|
new_nonce = new_nonce.to_bytes(32, 'little', signed=True)
|
||||||
data = new_nonce + struct.pack('<BQ', number, self.aux_hash)
|
data = new_nonce + struct.pack('<BQ', number, self.aux_hash)
|
||||||
return utils.calc_msg_key(data)
|
return calc_msg_key(data)
|
||||||
|
|
|
@ -8,7 +8,8 @@ from io import BytesIO
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from . import helpers as utils
|
from .helpers import generate_random_long, ensure_parent_dir_exists
|
||||||
|
|
||||||
from .crypto import rsa, CdnDecrypter
|
from .crypto import rsa, CdnDecrypter
|
||||||
from .errors import (
|
from .errors import (
|
||||||
RPCError, BrokenAuthKeyError, ServerError,
|
RPCError, BrokenAuthKeyError, ServerError,
|
||||||
|
@ -600,7 +601,7 @@ class TelegramBareClient:
|
||||||
is_large = file_size > 10 * 1024 * 1024
|
is_large = file_size > 10 * 1024 * 1024
|
||||||
part_count = (file_size + part_size - 1) // part_size
|
part_count = (file_size + part_size - 1) // part_size
|
||||||
|
|
||||||
file_id = utils.generate_random_long()
|
file_id = generate_random_long()
|
||||||
hash_md5 = md5()
|
hash_md5 = md5()
|
||||||
|
|
||||||
stream = open(file, 'rb') if isinstance(file, str) else BytesIO(file)
|
stream = open(file, 'rb') if isinstance(file, str) else BytesIO(file)
|
||||||
|
@ -678,7 +679,7 @@ class TelegramBareClient:
|
||||||
|
|
||||||
if isinstance(file, str):
|
if isinstance(file, str):
|
||||||
# Ensure that we'll be able to download the media
|
# Ensure that we'll be able to download the media
|
||||||
utils.ensure_parent_dir_exists(file)
|
ensure_parent_dir_exists(file)
|
||||||
f = open(file, 'wb')
|
f = open(file, 'wb')
|
||||||
else:
|
else:
|
||||||
f = file
|
f = file
|
||||||
|
|
|
@ -127,10 +127,10 @@ class TLGenerator:
|
||||||
# so they all can be serialized and sent, however, only the
|
# so they all can be serialized and sent, however, only the
|
||||||
# functions are "content_related".
|
# functions are "content_related".
|
||||||
builder.writeln(
|
builder.writeln(
|
||||||
'from {}.tl.tlobject import TLObject'.format('.' * depth)
|
'from telethon.tl.tlobject import TLObject'.format('.' * depth)
|
||||||
)
|
)
|
||||||
builder.writeln(
|
builder.writeln(
|
||||||
'from {}.tl import types'.format('.' * depth)
|
'import telethon.tl.types'.format('.' * depth)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add the relative imports to the namespaces,
|
# Add the relative imports to the namespaces,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user