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:
Will Thompson 2015-07-30 10:04:47 +01:00
parent d90a4c9acc
commit 98e40ee059

View file

@ -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):