From 1922ea681305aa5c90e47480c2c423aef62bf9f2 Mon Sep 17 00:00:00 2001 From: adosibalo <94008816+adosibalo@users.noreply.github.com> Date: Thu, 3 Aug 2023 04:20:08 -0500 Subject: [PATCH] Safely coerce responseHeaders to int (#2697) Co-authored-by: Enrico Minack --- github/Requester.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/github/Requester.py b/github/Requester.py index fca3c8b7..4ee54f04 100644 --- a/github/Requester.py +++ b/github/Requester.py @@ -665,11 +665,13 @@ class Requester: if Consts.headerRateRemaining in responseHeaders and Consts.headerRateLimit in responseHeaders: self.rate_limiting = ( - int(responseHeaders[Consts.headerRateRemaining]), - int(responseHeaders[Consts.headerRateLimit]), + # ints expected but sometimes floats returned: https://github.com/PyGithub/PyGithub/pull/2697 + int(float(responseHeaders[Consts.headerRateRemaining])), + int(float(responseHeaders[Consts.headerRateLimit])), ) if Consts.headerRateReset in responseHeaders: - self.rate_limiting_resettime = int(responseHeaders[Consts.headerRateReset]) + # ints expected but sometimes floats returned: https://github.com/PyGithub/PyGithub/pull/2697 + self.rate_limiting_resettime = int(float(responseHeaders[Consts.headerRateReset])) if Consts.headerOAuthScopes in responseHeaders: self.oauth_scopes = responseHeaders[Consts.headerOAuthScopes].split(", ")