@@ -211,7 +211,7 @@ Util_GetLine(BZ2FileObject *self, int n)
211211 self -> pos ++ ;
212212 if (bzerror != BZ_OK || buf == end )
213213 break ;
214- if (skipnextlf ) {
214+ if (skipnextlf ) {
215215 skipnextlf = 0 ;
216216 if (c == '\n' ) {
217217 /* Seeing a \n here with
@@ -498,7 +498,8 @@ BZ2File_read(BZ2FileObject *self, PyObject *args)
498498 buffersize = bytesrequested ;
499499 if (buffersize > INT_MAX ) {
500500 PyErr_SetString (PyExc_OverflowError ,
501- "requested number of bytes is more than a Python string can hold" );
501+ "requested number of bytes is "
502+ "more than a Python string can hold" );
502503 goto cleanup ;
503504 }
504505 ret = PyString_FromStringAndSize ((char * )NULL , buffersize );
@@ -1223,13 +1224,15 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
12231224
12241225 default :
12251226 error = 1 ;
1227+ break ;
12261228 }
12271229 if (error ) {
1228- PyErr_SetString (PyExc_ValueError , "invalid mode" );
1230+ PyErr_Format (PyExc_ValueError ,
1231+ "invalid mode char %c" , * mode );
12291232 return -1 ;
12301233 }
12311234 mode ++ ;
1232- if (* mode == 0 )
1235+ if (* mode == '\0' )
12331236 break ;
12341237 }
12351238
@@ -1240,7 +1243,10 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
12401243
12411244 file_args = Py_BuildValue ("(ssi)" , name , mode , buffering );
12421245 if (!file_args )
1243- goto error ;
1246+ return -1 ;
1247+
1248+ /* From now on, we have stuff to dealloc, so jump to error label
1249+ * instead of returning */
12441250
12451251 if (PyFile_Type .tp_init ((PyObject * )self , file_args , NULL ) < 0 )
12461252 goto error ;
@@ -1299,6 +1305,7 @@ BZ2File_dealloc(BZ2FileObject *self)
12991305 0 , NULL , NULL );
13001306 break ;
13011307 }
1308+ Util_DropReadAhead (self );
13021309 ((PyObject * )self )-> ob_type -> tp_free ((PyObject * )self );
13031310}
13041311
@@ -1362,7 +1369,7 @@ newlines are available only when reading.\n\
13621369#endif
13631370;
13641371
1365- statichere PyTypeObject BZ2File_Type = {
1372+ static PyTypeObject BZ2File_Type = {
13661373 PyObject_HEAD_INIT (NULL )
13671374 0 , /*ob_size*/
13681375 "bz2.BZ2File" , /*tp_name*/
@@ -1435,8 +1442,8 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args)
14351442
14361443 ACQUIRE_LOCK (self );
14371444 if (!self -> running ) {
1438- PyErr_SetString (PyExc_ValueError , "this object was already "
1439- " flushed" );
1445+ PyErr_SetString (PyExc_ValueError ,
1446+ "this object was already flushed" );
14401447 goto error ;
14411448 }
14421449
@@ -1551,8 +1558,10 @@ BZ2Comp_flush(BZ2CompObject *self)
15511558}
15521559
15531560static PyMethodDef BZ2Comp_methods [] = {
1554- {"compress" , (PyCFunction )BZ2Comp_compress , METH_VARARGS , BZ2Comp_compress__doc__ },
1555- {"flush" , (PyCFunction )BZ2Comp_flush , METH_NOARGS , BZ2Comp_flush__doc__ },
1561+ {"compress" , (PyCFunction )BZ2Comp_compress , METH_VARARGS ,
1562+ BZ2Comp_compress__doc__ },
1563+ {"flush" , (PyCFunction )BZ2Comp_flush , METH_NOARGS ,
1564+ BZ2Comp_flush__doc__ },
15561565 {NULL , NULL } /* sentinel */
15571566};
15581567
@@ -1625,7 +1634,7 @@ compress() function instead. The compresslevel parameter, if given,\n\
16251634must be a number between 1 and 9.\n\
16261635" );
16271636
1628- statichere PyTypeObject BZ2Comp_Type = {
1637+ static PyTypeObject BZ2Comp_Type = {
16291638 PyObject_HEAD_INIT (NULL )
16301639 0 , /*ob_size*/
16311640 "bz2.BZ2Compressor" , /*tp_name*/
@@ -1842,7 +1851,7 @@ data sequentially. If you want to decompress data in one shot, use the\n\
18421851decompress() function instead.\n\
18431852" );
18441853
1845- statichere PyTypeObject BZ2Decomp_Type = {
1854+ static PyTypeObject BZ2Decomp_Type = {
18461855 PyObject_HEAD_INIT (NULL )
18471856 0 , /*ob_size*/
18481857 "bz2.BZ2Decompressor" , /*tp_name*/
0 commit comments