From d31a696f324b02e606d965590ad02b2e87e5d16f Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 17 Dec 2018 13:02:22 +0100 Subject: [PATCH] Fix encoder breaking with bytes --- pyrogram/client/types/pyrogram_type.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/types/pyrogram_type.py b/pyrogram/client/types/pyrogram_type.py index f438a4ba..18faa9e8 100644 --- a/pyrogram/client/types/pyrogram_type.py +++ b/pyrogram/client/types/pyrogram_type.py @@ -43,5 +43,9 @@ def remove_none(obj): class Encoder(JSONEncoder): def default(self, o: PyrogramType): - content = {i: getattr(o, i) for i in filter(lambda x: not x.startswith("_"), o.__dict__)} + try: + content = {i: getattr(o, i) for i in filter(lambda x: not x.startswith("_"), o.__dict__)} + except AttributeError: + return repr(o) + return remove_none(OrderedDict([("_", "pyrogram:" + o.__class__.__name__)] + [i for i in content.items()]))