summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2004-02-14 00:02:45 (GMT)
committerGustavo Niemeyer <gustavo@niemeyer.net>2004-02-14 00:02:45 (GMT)
commita6e436e4b4f94062f274746fc5d109e4203bf658 (patch)
tree53e5f6dae22726c6714d3bf69d3360aff1c08574
parent238b267bf6da6311f7f2b1e6b1ee570f7d482db4 (diff)
downloadcpython-a6e436e4b4f94062f274746fc5d109e4203bf658.zip
cpython-a6e436e4b4f94062f274746fc5d109e4203bf658.tar.gz
cpython-a6e436e4b4f94062f274746fc5d109e4203bf658.tar.bz2
- Fixed #853061: allow BZ2Compressor.compress() to receive an empty string
as parameter.
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/bz2module.c3
2 files changed, 6 insertions, 0 deletions
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,