The `.encode()' and `.decode()' string methods were apparently too
convenient, so Python 3 doesn't do Base64 conversion like this.
Instead, we have to use the steam-powered `binascii'. And, to make
things even better, encoding produces `bytes' rather than `str' because,
err, it's not really text or something? No idea. Stoats.
from __future__ import with_statement
+import binascii as _B
import errno as _E
import os as _OS
from cStringIO import StringIO as _StringIO
def _b64(s):
"""Encode S as base64, without newlines, and trimming `=' padding."""
- return s.encode('base64').replace('\n', '').rstrip('=')
+ return _text(_B.b2a_base64(s)).replace('\n', '').rstrip('=')
def _unb64(s):
"""Decode S as base64 with trimmed `=' padding."""
- return (s + '='*((4 - len(s))%4)).decode('base64')
+ return _B.a2b_base64(s + '='*((4 - len(s))%4))
def _enc_metaval(val):
"""Encode VAL as a metadata item value, returning the result."""