base64.decodestring('') should return '' instead of raising an
exception. The bug fix for SF #430849 wasn't quite right. This
closes SF bug #595671. I'll backport this to Python 2.2.
One addition here is that there was no test of the base64 module in
Python 2.2 cvs yet, so I added that too.
--- /dev/null
+test_base64
+Testing decode string ... ok
+Testing encode string ... ok
+
+----------------------------------------------------------------------
+Ran 2 tests in 0.001s
+
+OK
if ( !PyArg_ParseTuple(args, "t#:a2b_base64", &ascii_data, &ascii_len) )
return NULL;
- if ( ascii_len == 0) {
- PyErr_SetString(Error, "Cannot decode empty input");
- return NULL;
- }
bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */
/* Allocate the buffer */
}
/* and set string size correctly */
- _PyString_Resize(&rv, bin_len);
+ if (bin_len > 0)
+ _PyString_Resize(&rv, bin_len);
return rv;
}