From a6e436e4b4f94062f274746fc5d109e4203bf658 Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Sat, 14 Feb 2004 00:02:45 +0000 Subject: [PATCH] - 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 275593b6e3..47e2859aab 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 82d35ae32b..c75011d492 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, -- 2.50.1