Skip to content

Commit

Permalink
Fix cyclic imports on Python 3.4 by moving Session one level up
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Jan 19, 2018
1 parent 519c113 commit 4d4e81e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions telethon/tl/session.py → telethon/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
from os.path import isfile as file_exists
from threading import Lock

from .. import utils
from ..tl import TLObject
from ..tl.types import (
from . import utils
from .crypto import AuthKey
from .tl import TLObject
from .tl.types import (
PeerUser, PeerChat, PeerChannel,
InputPeerUser, InputPeerChat, InputPeerChannel,
InputPhoto, InputDocument
Expand Down Expand Up @@ -118,7 +119,6 @@ def __init__(self, session_id):
tuple_ = c.fetchone()
if tuple_:
self._dc_id, self._server_address, self._port, key, = tuple_
from ..crypto import AuthKey
self._auth_key = AuthKey(data=key)

c.close()
Expand Down Expand Up @@ -173,7 +173,6 @@ def _check_migrate_json(self):
self._server_address = \
data.get('server_address', self._server_address)

from ..crypto import AuthKey
if data.get('auth_key_data', None) is not None:
key = b64decode(data['auth_key_data'])
self._auth_key = AuthKey(data=key)
Expand Down Expand Up @@ -228,7 +227,6 @@ def set_dc(self, dc_id, server_address, port):
c.execute('select auth_key from sessions')
tuple_ = c.fetchone()
if tuple_:
from ..crypto import AuthKey
self._auth_key = AuthKey(data=tuple_[0])
else:
self._auth_key = None
Expand Down
3 changes: 2 additions & 1 deletion telethon/telegram_bare_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
PhoneMigrateError, NetworkMigrateError, UserMigrateError
)
from .network import authenticator, MtProtoSender, Connection, ConnectionMode
from .tl import TLObject, Session
from .session import Session
from .tl import TLObject
from .tl.all_tlobjects import LAYER
from .tl.functions import (
InitConnectionRequest, InvokeWithLayerRequest, PingRequest
Expand Down
1 change: 0 additions & 1 deletion telethon/tl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .tlobject import TLObject
from .session import Session
from .gzip_packed import GzipPacked
from .tl_message import TLMessage
from .message_container import MessageContainer

0 comments on commit 4d4e81e

Please sign in to comment.