Message76226
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? |
|
Date |
User |
Action |
Args |
2008-11-22 00:41:20 | terry.reedy | set | recipients:
+ terry.reedy |
2008-11-22 00:41:19 | terry.reedy | set | messageid: <1227314479.85.0.870718938291.issue4387@psf.upfronthosting.co.za> |
2008-11-22 00:41:18 | terry.reedy | link | issue4387 messages |
2008-11-22 00:41:18 | terry.reedy | create | |
|