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.
This commit is contained in:
Barry Warsaw 2002-08-15 22:14:24 +00:00
parent 7ca993ed37
commit 0a51b58e6b
2 changed files with 3 additions and 11 deletions

View file

@ -346,10 +346,6 @@ binascii_a2b_base64(PyObject *self, PyObject *args)
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 */
@ -413,7 +409,8 @@ binascii_a2b_base64(PyObject *self, PyObject *args)
}
/* and set string size correctly */
_PyString_Resize(&rv, bin_len);
if (bin_len > 0)
_PyString_Resize(&rv, bin_len);
return rv;
}