[Python-bugs-list] base64 bug (PR#110)

ratman@nmt.edu ratman@nmt.edu
Fri, 15 Oct 1999 21:54:46 -0400 (EDT)


Full_Name: Jason Trowbridge
Version: 1.5.2
OS: Linux
Submission from: fenris.tcct.nmt.edu (129.138.3.169)


Under Linux, the base64 decoding functions generate a SystemError exception for
returning an error without setting the exception.  base64.decode() actually
seems to work just find, as the output file contains the decoded version of
the input file.  base64.decodestring() doesn't return anything (probably due
to the error indication?).

This problem is not present under Python 1.5.2 for Windows.  It is present
on two different linux systems, both my personal computer and the computers
at the campus computer center.  With both systems, the python source code was
downloaded, compiled, and installed in /usr/local.

The encoded test strings listed below are "Hello\n".  They were created by:
  echo "Hello" | uuencode -m -


Python 1.5.2 (#2, Oct  4 1999, 23:40:04)  [GCC egcs-2.91.66 19990314/Linux
(egc\s- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import base64
>>> import StringIO
>>> encoded = StringIO.StringIO('SGVsbG8K\n====')
>>> decoded = StringIO.StringIO()
>>> base64.decode(encoded, decoded)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python1.5/base64.py", line 33, in decode
    output.write(s)
  File "/usr/local/lib/python1.5/StringIO.py", line 102, in write
    if not s: return
SystemError: error return without exception set
>>> decoded.getvalue()
'Hello\012'


Python 1.5.2 (#2, Oct  4 1999, 23:40:04)  [GCC egcs-2.91.66 19990314/Linux
(egc\s- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import base64
>>> s = 'SGVsbG8K\n===='
>>> base64.decodestring(s)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python1.5/base64.py", line 46, in decodestring
    decode(f, g)
  File "/usr/local/lib/python1.5/base64.py", line 33, in decode
    output.write(s)
  File "/usr/local/lib/python1.5/StringIO.py", line 102, in write
    if not s: return
SystemError: error return without exception set