def base64_decodestring(s): if six.PY2: return base64.decodestring(s) else: if isinstance(s, str): s = s.encode('utf8') return base64.decodebytes(s).decode('utf8')