Small fix

This commit is contained in:
Alex Root Junior 2017-07-11 23:41:40 +03:00
parent d2c99fccf4
commit 0ae4f6d948
7 changed files with 19 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import os
import aiohttp
from ..exceptions import ValidationError, TelegramAPIError
from ..utils import json
log = logging.getLogger('aiogram')
@ -40,7 +41,7 @@ async def _check_result(method_name, response):
raise TelegramAPIError(f"The server returned HTTP {response.status}. Response body:\n[{body}]",
method_name, response.status, body)
result_json = await response.json()
result_json = await response.json(loads=json.loads)
if not result_json.get('ok'):
body = await response.text()

View file

@ -1,10 +1,10 @@
import asyncio
import io
import json
import aiohttp
from . import api
from ..utils import json
from ..utils.payload import generate_payload

View file

@ -1,5 +1,5 @@
import datetime
import json
from ..utils import json
import time
from .base import BaseBot

View file

@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
class Dispatcher:
def __init__(self, bot, loop=None):
self.bot: Bot = bot
self.bot: 'Bot' = bot
if loop is None:
loop = self.bot.loop

View file

@ -1,4 +1,4 @@
from . import ChatPhoto
from .chat_photo import ChatPhoto
from .base import Deserializable

12
aiogram/utils/json.py Normal file
View file

@ -0,0 +1,12 @@
try:
import ujson as json
except ImportError:
import json
def dumps(data):
return json.dumps(data)
def loads(data):
return json.loads(data)

View file

@ -1,3 +1,4 @@
ujson
aiohttp>=2.1.0
appdirs>=1.4.3
async-timeout>=1.2.1