#378 Fix `HTTPError.response` comparison.
Merged 5 years ago by jkaluza. Opened 5 years ago by jkaluza.
jkaluza/freshmaker httperror  into  master

file modified
+1 -1
@@ -132,7 +132,7 @@ 

                  **kwargs)

              r.raise_for_status()

          except requests.exceptions.RequestException as e:

-             if e.response and e.response.status_code == 401:

+             if e.response is not None and e.response.status_code == 401:

                  log.info("CCache file probably expired, removing it.")

                  os.unlink(conf.krb_auth_ccache_file)

              raise

The requests.Response evaluates to True if it is HTTP 200 OK,
otherwise it is False. The code changes by this commit however
wanted to check if e.response is None or set to some Response.
This did not work, because even if e.response was set, it evaluated
to False, because its status code was 401.

Pull-Request has been merged by jkaluza

5 years ago