Mercurial > kallithea
changeset 8423:bd1c1fa6524b stable
auth: simplify handling of Crowd json response (Issue #370)
Correct error where Crowd authentication didn't work due to urllib.readlines()
returning bytes and thus failing to be joined with a string.
json.loads is however happy to take bytes directly.
Fix error handling to also handle bytes without crashing.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sun, 10 May 2020 18:32:34 +0200 |
parents | eed428104177 |
children | db9718bde286 |
files | kallithea/lib/auth_modules/auth_crowd.py |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/auth_modules/auth_crowd.py Wed May 06 20:29:53 2020 +0200 +++ b/kallithea/lib/auth_modules/auth_crowd.py Sun May 10 18:32:34 2020 +0200 @@ -94,10 +94,10 @@ req.get_method = lambda: method global msg - msg = "" + msg = None try: rdoc = self.opener.open(req) - msg = "".join(rdoc.readlines()) + msg = rdoc.read() if not msg and empty_response_ok: rval = {} rval["status"] = True @@ -111,7 +111,7 @@ if not noformat: rval = {"status": False, "body": body, - "error": str(e) + "\n" + msg} + "error": "%s\n%r" % (e, msg)} else: rval = None return rval