From 8da6ffd7d5b1d1f25623076c65ff175c5def9d51 Mon Sep 17 00:00:00 2001 From: singer Date: Thu, 19 Oct 2017 18:47:55 +0300 Subject: [PATCH] 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 --- telethon/crypto/auth_key.py | 4 ++-- telethon/telegram_bare_client.py | 7 ++++--- telethon_generator/tl_generator.py | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/telethon/crypto/auth_key.py b/telethon/crypto/auth_key.py index 17a7f8ca..7dce3fa3 100644 --- a/telethon/crypto/auth_key.py +++ b/telethon/crypto/auth_key.py @@ -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(' 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 diff --git a/telethon_generator/tl_generator.py b/telethon_generator/tl_generator.py index 8fc6bb2d..81596e01 100644 --- a/telethon_generator/tl_generator.py +++ b/telethon_generator/tl_generator.py @@ -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,