base64.decodestring gives binascii.error

Alex Martelli aleax at aleax.it
Fri Dec 28 11:42:47 EST 2001


"Erik Myllymaki" <erik at pacific-shores.com> wrote in message
news:3C2C9D79.9050501 at pacific-shores.com...
> The '_' and '!' were in the original string that was then encoded, not
> in the resulting encoded string.

Then, it's clearly a bug in the base64 module you're using.  I
don't see it here:

>>> x=base64.encodestring('oh_my!')
>>> x
'b2hfbXkh\n'
>>> base64.decodestring(x)
'oh_my!'
>>>


[original context was -- oh those hateful add-in-front habits!:

> >>should base64.decodestring give a binascii.error if it encounters
> >>special chars like '_' and '!' ?
> >
> > Makes sense to me; after all, such characters should never be
> > in a string produced by base64, so the data must have been
> > damaged in transit -- raising an exceptions seems appropriate.

]


Alex






More information about the Python-list mailing list