From cd9a1067675db2de46f29fd2635056796b63f769 Mon Sep 17 00:00:00 2001 From: kairi003 Date: Sat, 13 Feb 2021 14:09:28 +0900 Subject: [PATCH] Fix bug in make_request method Values of credits updated in the make_request method were str --- imgurpython/client.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index 9c41ea6..ce40047 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -140,13 +140,14 @@ def make_request(self, method, route, data=None, force_anon=False): else: response = method_to_call(url, headers=header, data=data) - self.credits = { - 'UserLimit': response.headers.get('X-RateLimit-UserLimit'), - 'UserRemaining': response.headers.get('X-RateLimit-UserRemaining'), - 'UserReset': response.headers.get('X-RateLimit-UserReset'), - 'ClientLimit': response.headers.get('X-RateLimit-ClientLimit'), - 'ClientRemaining': response.headers.get('X-RateLimit-ClientRemaining') - } + if response.headers.get('X-RateLimit-UserLimit') is not None: + self.credits = { + 'UserLimit': int(response.headers.get('X-RateLimit-UserLimit')), + 'UserRemaining': int(response.headers.get('X-RateLimit-UserRemaining')), + 'UserReset': int(response.headers.get('X-RateLimit-UserReset')), + 'ClientLimit': int(response.headers.get('X-RateLimit-ClientLimit')), + 'ClientRemaining': int(response.headers.get('X-RateLimit-ClientRemaining')) + } # Rate-limit check if response.status_code == 429: