From 38eae1e21ab9037203dd5a9dced36502506d5cdc Mon Sep 17 00:00:00 2001 From: Jahongir Qurbonov Date: Tue, 16 Sep 2025 11:12:37 +0500 Subject: [PATCH] Rollback match case --- client/src/telethon/_impl/mtsender/sender.py | 29 ++++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/client/src/telethon/_impl/mtsender/sender.py b/client/src/telethon/_impl/mtsender/sender.py index 37ab838c..b5fa4eec 100644 --- a/client/src/telethon/_impl/mtsender/sender.py +++ b/client/src/telethon/_impl/mtsender/sender.py @@ -418,21 +418,20 @@ class Sender: results = self.mtp.deserialize(self._mtp_buffer) for result in results: - match result: - case Update(body=body): - self._process_update(body) - case RpcResult(): - self._process_result(result) - case RpcError(): - self._process_error(result) - case BadMessageError(): - self._process_bad_message(result) - case DeserializationFailure(): - self._process_deserialize_error(result) - case _: - raise RuntimeError( - f"unexpected result type {type(result).__name__}: {result}" - ) + if isinstance(result, Update): + self._process_update(result.body) + elif isinstance(result, RpcResult): + self._process_result(result) + elif isinstance(result, RpcError): + self._process_error(result) + elif isinstance(result, BadMessageError): + self._process_bad_message(result) + elif isinstance(result, DeserializationFailure): + self._process_deserialize_error(result) + else: + raise RuntimeError( + f"unexpected result type {type(result).__name__}: {result}" + ) def _process_update(self, update: bytes | bytearray | memoryview) -> None: try: