From 9b8cfc6f6fac6ad0ec15fab6759d355112421ac9 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Tue, 12 Jun 2018 15:15:58 +0800 Subject: [PATCH] github: avoid TypeError when github returns 502 or similar ...without the ratelimit header --- nvchecker/source/github.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvchecker/source/github.py b/nvchecker/source/github.py index c1c755c..36a01c2 100644 --- a/nvchecker/source/github.py +++ b/nvchecker/source/github.py @@ -122,7 +122,8 @@ def get_next_page_url(links): def check_ratelimit(exc, name): res = exc.response - n = int(res.headers.get('X-RateLimit-Remaining')) + # default -1 is used to re-raise the exception + n = int(res.headers.get('X-RateLimit-Remaining', -1)) if n == 0: reset = int(res.headers.get('X-RateLimit-Reset')) logger.error('rate limited, resetting at %s. '