mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 07:06:26 +01:00
Bot._requestUrl: raise if method not in ('GET', 'POST')
If this happens, there is a bug in the library. Better to raise the error explicitly rather than return a value of a totally unexpected type and crash later.
This commit is contained in:
parent
d90a4c9acc
commit
98e40ee059
1 changed files with 2 additions and 1 deletions
|
@ -587,6 +587,8 @@ class Bot(TelegramObject):
|
|||
Returns:
|
||||
A JSON object.
|
||||
"""
|
||||
if method not in ('POST', 'GET'):
|
||||
raise ValueError("Method '{}' is neither 'POST' nor 'GET'".format(method))
|
||||
|
||||
if method == 'POST':
|
||||
try:
|
||||
|
@ -618,7 +620,6 @@ class Bot(TelegramObject):
|
|||
except URLError as e:
|
||||
raise TelegramError(str(e))
|
||||
|
||||
return 0 # if not a POST or GET request
|
||||
|
||||
def _parseAndCheckTelegram(self,
|
||||
json_data):
|
||||
|
|
Loading…
Reference in a new issue