Issue634637

classification
Title: base64/binascii difference from Python
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, dalke, leouserz
Priority: low Keywords:

Created on 2002-11-06.20:15:27 by dalke, last changed 2007-05-19.17:27:37 by cgroves.

Messages
msg789 (view) Author: Andrew Dalke (dalke) Date: 2002-11-06.20:15:27
A poorly formatted base64-encoded email I received ends
with
something like

L3A+DQo8cD4gPC9wPg0KPC9IVE1MPg0KMTEzNmFwaVY1LTUzOWtCZU02OTE2
dWN1TDItMzg2eFhSZTMzMzdBdkZHMS0xMThiSm5sNDc=
_______________________________________________
<footer>

Under Python this is turned into

[dalke@zebulon ~/tmp]$ python show_problem.py
/p>
<p> </p>
</HTML>
1136apiV5-539kBeM6916ucuL2-386xXRe3337AvFG1-118bJnl47
[dalke@zebulon ~/tmp]$

Under Jython this raises an exception

[dalke@zebulon ~/tmp]$ jython show_problem.py
Traceback (innermost last):
  File "show_problem.py", line 10, in ?
  File "/home/dalke/jython-2.1/Lib/base64.py", line 47,
in decodestring
  File "/home/dalke/jython-2.1/Lib/base64.py", line 31,
in decode
binascii.Error: Incorrect padding
[dalke@zebulon ~/tmp]$


Here is the "show_problem.py" script

import base64

s = (
    "L3A+DQo8cD4gPC9wPg0KPC9IVE1MPg0K"
    "MTEzNmFwaVY1LTUzOWtCZU02OTE2\n"
    "dWN1TDItMzg2eFhSZTMzMzdBdkZHMS0xMThiSm5sNDc=\n"
    "_______________________________________________\n"
    "<footer>\n"
    )

print base64.decodestring(s)

I could find no discussion of this on the newsgroups nor
in the bug lists for Python nor Jython.

I'll let you all and the CPython people decide on which
implementation is at fault or not :)

                                              Andrew
msg790 (view) Author: Deleted User leouserz (leouserz) Date: 2007-01-15.17:35:09
oh yeah! This bug does not happen in jython3005.  In fact, the output from jython is the same from python2.5:
me% jython show_problem.py
/p>
<p> </p>
</HTML>
1136apiV5-539kBeM6916ucuL2-386xXRe3337AvFG1-118bJnl47

me% python show_problem.py
/p>
<p> </p>
</HTML>
1136apiV5-539kBeM6916ucuL2-386xXRe3337AvFG1-118bJnl47

and according to the bug report its supposed to be:
1136apiV5-539kBeM6916ucuL2-386xXRe3337AvFG1-118bJnl47

maybe this was a bug in one of the older python libraries and has subsequently been fixed by upgrading the library?
msg791 (view) Author: Charlie Groves (cgroves) Date: 2007-05-19.17:27:37
Looks like this is fixed under 2.2b2.
History
Date User Action Args
2002-11-06 20:15:27dalkecreate