🐛 TLObject: Fix read return None instead of raise KeyError
This commit is contained in:
parent
6c078c38d0
commit
2a7b83d668
@ -18,7 +18,7 @@
|
||||
|
||||
from io import BytesIO
|
||||
from json import dumps
|
||||
from typing import cast, List, Any, Union, Dict
|
||||
from typing import cast, List, Any, Union, Dict, Optional
|
||||
|
||||
from ..all import objects
|
||||
|
||||
@ -29,8 +29,11 @@ class TLObject:
|
||||
QUALNAME = "Base"
|
||||
|
||||
@classmethod
|
||||
def read(cls, b: BytesIO, *args: Any) -> Any:
|
||||
return cast(TLObject, objects[int.from_bytes(b.read(4), "little")]).read(b, *args)
|
||||
def read(cls, b: BytesIO, *args: Any) -> Optional["TLObject"]:
|
||||
function_name = objects.get(int.from_bytes(b.read(4), "little"))
|
||||
if not function_name:
|
||||
return None
|
||||
return cast(TLObject, function_name).read(b, *args)
|
||||
|
||||
def write(self, *args: Any) -> bytes:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user