New submission from Terry J. Reedy <[EMAIL PROTECTED]>: Binascii b2a_xxx functions accept 'binary data' and return ascii-encoded bytes. The corresponding a2b_xxx functions turn the ascii-encoded bytes back to 'binary data' (bytes). If the binary data is bytes, these should be inverses of each other.
Somewhat surprisingly to me (because the corresponding base64 module functions raise "TypeError: expected bytes, not str") 3.0 strings (unicode) are accepted as 'binary data', though they will not 'round-trip'. Ascii chars almost do >>> a='aaaa' >>> c=b.b2a_base64(a) >>> c b'YWFhYQ==\n' >>> d=b.a2b_base64(c) >>> d b'aaaa' But general unicode chars generate nonsense. >>> a='\u1000' >>> c=b.b2a_base64(a) >>> c b'4YCA\n' >>> d=b.a2b_base64(c) >>> d b'\xe1\x80\x80' I also tried b2a_uu. Is this a bug? ---------- components: Extension Modules messages: 76226 nosy: tjreedy severity: normal status: open title: binascii b2a functions accept strings (unicode) as data versions: Python 3.0 _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4387> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com