* Modules/bz2module.c
(BZ2File_dealloc): Call Util_DropReadAhead().
(*): Included aesthetic changes by Neal Norwitz.
diff --git a/Modules/bz2module.c b/Modules/bz2module.c
index 9c37906..62e550d 100644
--- a/Modules/bz2module.c
+++ b/Modules/bz2module.c
@@ -211,7 +211,7 @@
self->pos++;
if (bzerror != BZ_OK || buf == end)
break;
- if (skipnextlf ) {
+ if (skipnextlf) {
skipnextlf = 0;
if (c == '\n') {
/* Seeing a \n here with
@@ -498,7 +498,8 @@
buffersize = bytesrequested;
if (buffersize > INT_MAX) {
PyErr_SetString(PyExc_OverflowError,
- "requested number of bytes is more than a Python string can hold");
+ "requested number of bytes is "
+ "more than a Python string can hold");
goto cleanup;
}
ret = PyString_FromStringAndSize((char *)NULL, buffersize);
@@ -1223,13 +1224,15 @@
default:
error = 1;
+ break;
}
if (error) {
- PyErr_SetString(PyExc_ValueError, "invalid mode");
+ PyErr_Format(PyExc_ValueError,
+ "invalid mode char %c", *mode);
return -1;
}
mode++;
- if (*mode == 0)
+ if (*mode == '\0')
break;
}
@@ -1240,7 +1243,10 @@
file_args = Py_BuildValue("(ssi)", name, mode, buffering);
if (!file_args)
- goto error;
+ return -1;
+
+ /* From now on, we have stuff to dealloc, so jump to error label
+ * instead of returning */
if (PyFile_Type.tp_init((PyObject *)self, file_args, NULL) < 0)
goto error;
@@ -1299,6 +1305,7 @@
0, NULL, NULL);
break;
}
+ Util_DropReadAhead(self);
((PyObject*)self)->ob_type->tp_free((PyObject *)self);
}
@@ -1362,7 +1369,7 @@
#endif
;
-statichere PyTypeObject BZ2File_Type = {
+static PyTypeObject BZ2File_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"bz2.BZ2File", /*tp_name*/
@@ -1435,8 +1442,8 @@
ACQUIRE_LOCK(self);
if (!self->running) {
- PyErr_SetString(PyExc_ValueError, "this object was already "
- "flushed");
+ PyErr_SetString(PyExc_ValueError,
+ "this object was already flushed");
goto error;
}
@@ -1551,8 +1558,10 @@
}
static PyMethodDef BZ2Comp_methods[] = {
- {"compress", (PyCFunction)BZ2Comp_compress, METH_VARARGS, BZ2Comp_compress__doc__},
- {"flush", (PyCFunction)BZ2Comp_flush, METH_NOARGS, BZ2Comp_flush__doc__},
+ {"compress", (PyCFunction)BZ2Comp_compress, METH_VARARGS,
+ BZ2Comp_compress__doc__},
+ {"flush", (PyCFunction)BZ2Comp_flush, METH_NOARGS,
+ BZ2Comp_flush__doc__},
{NULL, NULL} /* sentinel */
};
@@ -1625,7 +1634,7 @@
must be a number between 1 and 9.\n\
");
-statichere PyTypeObject BZ2Comp_Type = {
+static PyTypeObject BZ2Comp_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"bz2.BZ2Compressor", /*tp_name*/
@@ -1842,7 +1851,7 @@
decompress() function instead.\n\
");
-statichere PyTypeObject BZ2Decomp_Type = {
+static PyTypeObject BZ2Decomp_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"bz2.BZ2Decompressor", /*tp_name*/