mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-06 21:20:22 +03:00
Get rid of the exception constant
This is antipattern because 'raise' doesn't copy the specified exception object, but simply throws a reference onto, so if the user wants to change the exception object in the handler, the constant will be changed as well.
This commit is contained in:
parent
11896bb0e5
commit
a248be5eca
|
@ -53,7 +53,7 @@ class _TakeoutClient:
|
||||||
wrapped = []
|
wrapped = []
|
||||||
for r in requests:
|
for r in requests:
|
||||||
if not isinstance(r, TLRequest):
|
if not isinstance(r, TLRequest):
|
||||||
raise _NOT_A_REQUEST
|
raise _NOT_A_REQUEST()
|
||||||
await r.resolve(self, utils)
|
await r.resolve(self, utils)
|
||||||
wrapped.append(functions.InvokeWithTakeoutRequest(takeout_id, r))
|
wrapped.append(functions.InvokeWithTakeoutRequest(takeout_id, r))
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from ..errors import MultiError, RPCError
|
||||||
from ..tl import TLObject, TLRequest, types, functions
|
from ..tl import TLObject, TLRequest, types, functions
|
||||||
from ..helpers import retry_range
|
from ..helpers import retry_range
|
||||||
|
|
||||||
_NOT_A_REQUEST = TypeError('You can only invoke requests, not types!')
|
_NOT_A_REQUEST = lambda: TypeError('You can only invoke requests, not types!')
|
||||||
|
|
||||||
|
|
||||||
class UserMethods(TelegramBaseClient):
|
class UserMethods(TelegramBaseClient):
|
||||||
|
@ -16,7 +16,7 @@ class UserMethods(TelegramBaseClient):
|
||||||
requests = (request if utils.is_list_like(request) else (request,))
|
requests = (request if utils.is_list_like(request) else (request,))
|
||||||
for r in requests:
|
for r in requests:
|
||||||
if not isinstance(r, TLRequest):
|
if not isinstance(r, TLRequest):
|
||||||
raise _NOT_A_REQUEST
|
raise _NOT_A_REQUEST()
|
||||||
await r.resolve(self, utils)
|
await r.resolve(self, utils)
|
||||||
|
|
||||||
# Avoid making the request if it's already in a flood wait
|
# Avoid making the request if it's already in a flood wait
|
||||||
|
|
Loading…
Reference in New Issue
Block a user