Skip to content

Commit 0b6b598

Browse files
committed
Log unknown constructors
1 parent caecbef commit 0b6b598

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pyrogram/api/core/object.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,31 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import logging
1920
from collections import OrderedDict
2021
from datetime import datetime
2122
from io import BytesIO
2223
from json import JSONEncoder, dumps
2324

2425
from ..all import objects
2526

27+
log = logging.getLogger(__name__)
28+
2629

2730
class Object:
2831
all = {}
2932

3033
@staticmethod
3134
def read(b: BytesIO, *args):
32-
return Object.all[int.from_bytes(b.read(4), "little")].read(b, *args)
35+
constructor_id = int.from_bytes(b.read(4), "little")
36+
37+
try:
38+
return Object.all[constructor_id].read(b, *args)
39+
except KeyError:
40+
log.error("Unknown constructor found: {}. Full data: {}".format(
41+
hex(constructor_id),
42+
b.getvalue().hex())
43+
)
3344

3445
def write(self, *args) -> bytes:
3546
pass

0 commit comments

Comments
 (0)