diff options
author | Barry Warsaw <barry@python.org> | 2002-08-15 22:14:24 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-08-15 22:14:24 (GMT) |
commit | 0a51b58e6b5ffd3cc17722f4ae19893ed486f3c9 (patch) | |
tree | 8779c759e1dfd74bd7e3d02042d12294099ba604 /Modules | |
parent | 7ca993ed37f84491885cc2d96ae7d1a575a7a2f4 (diff) | |
download | cpython-0a51b58e6b5ffd3cc17722f4ae19893ed486f3c9.zip cpython-0a51b58e6b5ffd3cc17722f4ae19893ed486f3c9.tar.gz cpython-0a51b58e6b5ffd3cc17722f4ae19893ed486f3c9.tar.bz2 |
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.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/binascii.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c index 0fe85fc..c56d528 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -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; } |