def base64_encodebytes(data): if hasattr(base64, "encodebytes"): return base64.encodebytes(data) return base64.encodestring(data)