Index: Lib/urlparse.py =================================================================== --- Lib/urlparse.py (revision 78969) +++ Lib/urlparse.py (working copy) @@ -268,26 +268,6 @@ else: return url, '' -# unquote method for parse_qs and parse_qsl -# Cannot use directly from urllib as it would create circular reference. -# urllib uses urlparse methods ( urljoin) - -_hextochr = dict(('%02x' % i, chr(i)) for i in range(256)) -_hextochr.update(('%02X' % i, chr(i)) for i in range(256)) - -def unquote(s): - """unquote('abc%20def') -> 'abc def'.""" - res = s.split('%') - for i in xrange(1, len(res)): - item = res[i] - try: - res[i] = _hextochr[item[:2]] + item[2:] - except KeyError: - res[i] = '%' + item - except UnicodeDecodeError: - res[i] = unichr(int(item[:2], 16)) + item[2:] - return "".join(res) - def parse_qs(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument. @@ -333,6 +313,8 @@ Returns a list, as G-d intended. """ + # Local import (as a global import would create a circular dependency) + from urllib import unquote pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')] r = [] for name_value in pairs: