mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-10 10:49:39 +00:00
Add a more descriptive error when serializing bytes
This commit is contained in:
@@ -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 isinstance(data, str):
|
if not isinstance(data, bytes):
|
||||||
data = data.encode('utf-8')
|
if isinstance(data, str):
|
||||||
|
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:
|
||||||
|
Reference in New Issue
Block a user