From a6e436e4b4f94062f274746fc5d109e4203bf658 Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Sat, 14 Feb 2004 00:02:45 +0000 Subject: - Fixed #853061: allow BZ2Compressor.compress() to receive an empty string as parameter. --- Misc/NEWS | 3 +++ Modules/bz2module.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 275593b..47e2859 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -226,6 +226,9 @@ Extension modules - itertools.izip() with no arguments now returns an empty iterator instead of raising a TypeError exception. +- Fixed #853061: allow BZ2Compressor.compress() to receive an empty string + as parameter. + Library ------- diff --git a/Modules/bz2module.c b/Modules/bz2module.c index 82d35ae..c75011d 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -1503,6 +1503,9 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s#", &data, &datasize)) return NULL; + if (datasize == 0) + return PyString_FromString(""); + ACQUIRE_LOCK(self); if (!self->running) { PyErr_SetString(PyExc_ValueError, -- cgit v0.12