How to correct the "Incorrect Padding" Error while decoding the binary data in Debian Server

Asked by Pavithra on 2011-10-20

I have created a binary field for file upload option and i need to read and process the data of the uploaded file... When i try to decode the data in the binary file.. I am getting following Error...

ERROR:web-services:Uncaught exception Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/openerp-server/osv/", line 122, in wrapper return f(self, dbname, *args, **kwargs) File "/usr/lib/python2.5/site-packages/openerp-server/osv/", line 176, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/usr/lib/python2.5/site-packages/openerp-server/osv/", line 167, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/usr/lib/python2.5/site-packages/openerp-server/addons/account_voucher/", line 426, in get_file_data datas = base64.decodestring(data.import_file) File "/usr/lib/python2.5/", line 321, in decodestring return binascii.a2b_base64(s) Error: Incorrect padding

Can anyone please tell me how to correct it????

Question information

English Edit question
Odoo Web Client Edit question
No assignee Edit question
Last query:
Last reply:


this might be the following bug:

The issue is covered here as well, as a generic python issue:

I am personally curious if the following comment on that page does something in your case:

"It is possible that the encoding has been done in an url-safe manner. If this is the case, you will be able to see minus and underscore characters in your data, and you should be able to decode it by using base64.b64decode(data.import_file, '-_')"

By the way, what version are you running?

Good luck,

Pavithra (pavithra-lakshmanan) said : #2

Hi Stefan,

        Thanks for your reply.. I am using 6.0 Version.

        I have tried as per your comment to decode my data. But it dint work. Got the same error.
        Is there any other options to solve this issue?????

Launchpad Janitor (janitor) said : #3

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

If you are using 6.0.0, upgrade to 6.0.3. If you still have the problem, reopen the bug report.

Pavithra (pavithra-lakshmanan) said : #5


       Thanks for your help.. I got it fixed now.