From e88dd1c32c2961e0fe40b09c48904451fa1eba9a Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 6 Mar 2016 16:16:40 +0200 Subject: Issue #2202: Fix UnboundLocalError in AbstractDigestAuthHandler.get_algorithm_impls Raise ValueError if algorithm is not MD5 or SHA. Initial patch by Mathieu Dupuy. --- Lib/urllib/request.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/urllib/request.py') diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 4c1651861b3..fc8ef7f91b0 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1111,6 +1111,9 @@ class AbstractDigestAuthHandler: elif algorithm == 'SHA': H = lambda x: hashlib.sha1(x.encode("ascii")).hexdigest() # XXX MD5-sess + else: + raise ValueError("Unsupported digest authentication " + "algorithm %r" % algorithm) KD = lambda s, d: H("%s:%s" % (s, d)) return H, KD -- cgit v1.2.3