Skip to content

Commit ec15534

Browse files
authored
Merge pull request pyrogram#332 from pyrogram/add-bind
Add .bind() method to re-enable bound-methods after deserialization
2 parents 9afd244 + 1609efb commit ec15534

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pyrogram/client/types/object.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ class Object(metaclass=Meta):
3232
def __init__(self, client: "pyrogram.BaseClient" = None):
3333
self._client = client
3434

35-
if self._client is None:
36-
del self._client
35+
def bind(self, client: "pyrogram.BaseClient"):
36+
"""Bind a Client instance to this Pyrogram Object
37+
38+
Parameters:
39+
client (:obj:`Client`):
40+
The Client instance to bind this object with. Useful to re-enable bound methods after serializing and
41+
deserializing Pyrogram objects with ``repr`` and ``eval``.
42+
"""
43+
self._client = client
3744

3845
@staticmethod
3946
def default(obj: "Object"):

0 commit comments

Comments
 (0)