Fix #117: TypeError with LazyProxy object in keyboards

This commit is contained in:
Alex RootJunior 2019-04-07 14:13:54 +03:00
parent f228329b01
commit 25bdb9cf4d
2 changed files with 8 additions and 0 deletions

View file

@ -4,6 +4,8 @@ import io
import typing
from typing import TypeVar
from babel.support import LazyProxy
from .fields import BaseField
from ..utils import json
from ..utils.mixins import ContextInstanceMixin
@ -163,6 +165,8 @@ class TelegramObject(ContextInstanceMixin, metaclass=MetaTelegramObject):
value = self.props[name].export(self)
if isinstance(value, TelegramObject):
value = value.to_python()
if isinstance(value, LazyProxy):
value = str(value)
result[self.props_aliases.get(name, name)] = value
return result

View file

@ -1,6 +1,8 @@
import datetime
import secrets
from babel.support import LazyProxy
from aiogram import types
from . import json
@ -57,6 +59,8 @@ def prepare_arg(value):
return int((now + value).timestamp())
elif isinstance(value, datetime.datetime):
return round(value.timestamp())
elif isinstance(value, LazyProxy):
return str(value)
return value