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:
singer 2017-10-19 18:47:55 +03:00
parent 050cd95d32
commit 8da6ffd7d5
3 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import struct
from hashlib import sha1
from .. import helpers as utils
from ..helpers import calc_msg_key
from ..extensions import BinaryReader
@ -20,4 +20,4 @@ class AuthKey:
"""
new_nonce = new_nonce.to_bytes(32, 'little', signed=True)
data = new_nonce + struct.pack('<BQ', number, self.aux_hash)
return utils.calc_msg_key(data)
return calc_msg_key(data)

View File

@ -8,7 +8,8 @@ from io import BytesIO
from threading import Lock
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 .errors import (
RPCError, BrokenAuthKeyError, ServerError,
@ -600,7 +601,7 @@ class TelegramBareClient:
is_large = file_size > 10 * 1024 * 1024
part_count = (file_size + part_size - 1) // part_size
file_id = utils.generate_random_long()
file_id = generate_random_long()
hash_md5 = md5()
stream = open(file, 'rb') if isinstance(file, str) else BytesIO(file)
@ -678,7 +679,7 @@ class TelegramBareClient:
if isinstance(file, str):
# 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')
else:
f = file

View File

@ -127,10 +127,10 @@ class TLGenerator:
# so they all can be serialized and sent, however, only the
# functions are "content_related".
builder.writeln(
'from {}.tl.tlobject import TLObject'.format('.' * depth)
'from telethon.tl.tlobject import TLObject'.format('.' * depth)
)
builder.writeln(
'from {}.tl import types'.format('.' * depth)
'import telethon.tl.types'.format('.' * depth)
)
# Add the relative imports to the namespaces,