Fix exception when handling login failure

Logging in with an invalid token would throw a TypeError due to improper
passing of arguments to HTTPClient._token.  Fix by properly passing the
keyword only bot argument.
This commit is contained in:
Hornwitser 2016-06-14 18:48:03 +02:00
parent 4dbac9423d
commit e516c24746

View File

@ -189,13 +189,13 @@ class HTTPClient:
@asyncio.coroutine
def static_login(self, token, *, bot):
old_state = (self.token, self.bot_token)
old_token, old_bot = self.token, self.bot_token
self._token(token, bot=bot)
try:
data = yield from self.get(self.ME)
except HTTPException as e:
self._token(*old_state)
self._token(old_token, bot=old_bot)
if e.response.status == 401:
raise LoginFailure('Improper token has been passed.') from e
raise e