New submission from Dmitry <d...@dniq-online.com>:

All base64 decoding methods fail to decode a valid base64 string, throwing 
'incorrect padding' regardless of the string padding.

Here's an example:

>>> base64.urlsafe_b64decode('AQAAQDhAAMAAQAAAAAAAAthAAAAJDczODFmZDM2LTNiOTYtNDVmYS04MjQ2LWRkYzJkMmViYjQ2YQ===')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/export/apps/python/3.6/lib/python3.6/base64.py", line 133, in 
urlsafe_b64decode
    return b64decode(s)
  File "/export/apps/python/3.6/lib/python3.6/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

The same string gets decoded without any issues using Perl's MIME::Base64 
module or Java. So far Python's base64 module is the only one that fails to 
decode it.

----------
components: Extension Modules
messages: 318691
nosy: dniq
priority: normal
severity: normal
status: open
title: base64 throws 'incorrect padding' exception even though the string 
length is a multiple of 4
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33770>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to