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.

Author mbecker
Recipients mbecker
Date 2008-11-15.11:11:23
SpamBayes Score 5.844149e-07
Marked as misclassified No
Message-id <1226747485.51.0.230106735206.issue4329@psf.upfronthosting.co.za>
In-reply-to
Content
See below. unicode string causes exception. Explicitly converting it to
a regular string addresses the issue. I only noticed this because my
input string changed to unicode after updating python to 2.6 and django
to 1.0.

>>> import base64
>>>
a=u'aHR0cDovL3NvdXJjZWZvcmdlLm5ldC90cmFja2VyMi8_ZnVuYz1kZXRhaWwmYWlkPTIyNTg5MzUmZ3JvdXBfaWQ9MTI2OTQmYXRpZD0xMTI2OTQ='
>>> b=base64.urlsafe_b64decode(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/base64.py", line 112, in urlsafe_b64decode
    return b64decode(s, '-_')
  File "/usr/local/lib/python2.6/base64.py", line 71, in b64decode
    s = _translate(s, {altchars[0]: '+', altchars[1]: '/'})
  File "/usr/local/lib/python2.6/base64.py", line 36, in _translate
    return s.translate(''.join(translation))
TypeError: character mapping must return integer, None or unicode
>>> b=base64.urlsafe_b64decode(str(a))
>>> b
'http://sourceforge.net/tracker2/?func=detail&aid=2258935&group_id=12694&atid=112694'
History
Date User Action Args
2008-11-15 11:11:25mbeckersetrecipients: + mbecker
2008-11-15 11:11:25mbeckersetmessageid: <1226747485.51.0.230106735206.issue4329@psf.upfronthosting.co.za>
2008-11-15 11:11:24mbeckerlinkissue4329 messages
2008-11-15 11:11:23mbeckercreate