This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 terry.reedy
收信人 terry.reedy
日期 2008-11-22.00:41:18
SpamBayes Score 9.079555e-05
Marked as misclassified
Message-id <1227314479.85.0.870718938291.issue4387@psf.upfronthosting.co.za>
In-reply-to
内容
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?
历史
日期 用户 动作 参数
2008-11-22 00:41:20terry.reedy修改recipients: + terry.reedy
2008-11-22 00:41:19terry.reedy修改messageid: <1227314479.85.0.870718938291.issue4387@psf.upfronthosting.co.za>
2008-11-22 00:41:18terry.reedy链接issue4387 messages
2008-11-22 00:41:18terry.reedy创建