# HG changeset patch # User Mads Kiilerich # Date 2020-05-10 18:32:34 # Node ID bd1c1fa6524b84c2ea9a5beb6e9e26f9ed737332 # Parent eed4281041774f299e416a6833132e981c1f6aee 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. diff --git a/kallithea/lib/auth_modules/auth_crowd.py b/kallithea/lib/auth_modules/auth_crowd.py --- a/kallithea/lib/auth_modules/auth_crowd.py +++ b/kallithea/lib/auth_modules/auth_crowd.py @@ -94,10 +94,10 @@ class CrowdServer(object): 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 @@ class CrowdServer(object): if not noformat: rval = {"status": False, "body": body, - "error": str(e) + "\n" + msg} + "error": "%s\n%r" % (e, msg)} else: rval = None return rval