From 739779c29d24ed0c5393943da2ad2d72d70515d7 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 26 Apr 2018 12:12:38 +0200 Subject: [PATCH] Remove Client objects representation --- pyrogram/api/core/object.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pyrogram/api/core/object.py b/pyrogram/api/core/object.py index e3092212..8a757f35 100644 --- a/pyrogram/api/core/object.py +++ b/pyrogram/api/core/object.py @@ -72,10 +72,15 @@ class Encoder(JSONEncoder): else: return repr(o) - if objects.get(getattr(o, "ID", "")).startswith("pyrogram.client"): - return remove_none(OrderedDict([i for i in content.items()])) + o = objects.get(getattr(o, "ID", None), None) + + if o is not None: + if o.startswith("pyrogram.client"): + r = remove_none(OrderedDict([i for i in content.items()])) + r.pop("client", None) + + return r + else: + return OrderedDict([("_", o)] + [i for i in content.items()]) else: - return OrderedDict( - [("_", objects.get(getattr(o, "ID", None), None))] - + [i for i in content.items()] - ) + return None