From 98e40ee059e4f10ec3601568ac71f6033b5cbb78 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 30 Jul 2015 10:04:47 +0100 Subject: [PATCH] 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. --- telegram/bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telegram/bot.py b/telegram/bot.py index 89c675822..d4e9ba954 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -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):