Fix .start() failing on some terminals

This commit is contained in:
Lonami Exo 2018-04-08 11:47:18 +02:00
parent 5fd6155168
commit 8e01946957

View File

@ -356,7 +356,14 @@ class TelegramClient(TelegramBareClient):
me = self.sign_in(phone=phone, password=password)
# We won't reach here if any step failed (exit by exception)
print('Signed in successfully as', utils.get_display_name(me))
signed, name = 'Signed in successfully as', utils.get_display_name(me)
try:
print(signed, name)
except UnicodeEncodeError:
# Some terminals don't support certain characters
print(signed, name.encode('utf-8', errors='ignore')
.decode('ascii', errors='ignore'))
self._check_events_pending_resolve()
return self