def urlencode(data): if isinstance(data, dict): data = data.items() params = [] for name, value in data: if isinstance(value, util.utype): value = value.encode('utf-8') params.append((name, value)) return util.urlencode(params)