mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-15 18:42:23 +03:00
Add a more descriptive error when serializing bytes
This commit is contained in:
parent
e427559d4c
commit
3db13ccdd2
|
@ -93,8 +93,11 @@ class TLObject:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def serialize_bytes(data):
|
def serialize_bytes(data):
|
||||||
"""Write bytes by using Telegram guidelines"""
|
"""Write bytes by using Telegram guidelines"""
|
||||||
|
if not isinstance(data, bytes):
|
||||||
if isinstance(data, str):
|
if isinstance(data, str):
|
||||||
data = data.encode('utf-8')
|
data = data.encode('utf-8')
|
||||||
|
else:
|
||||||
|
raise ValueError('bytes or str expected, not', type(data))
|
||||||
|
|
||||||
r = []
|
r = []
|
||||||
if len(data) < 254:
|
if len(data) < 254:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user