def parse_arg_list(query_string): """Parse a query string into a list of `(name, value)` tuples.""" args = [] if not query_string: return args for arg in query_string.split('&'): nv = arg.split('=', 1) if len(nv) == 2: (name, value) = nv else: (name, value) = (nv[0], empty) name = unquote(name.replace('+', ' ')) if isinstance(name, str): name = unicode(name, 'utf-8') value = unquote(value.replace('+', ' ')) if isinstance(value, str): value = unicode(value, 'utf-8') args.append((name, value)) return args