@@ -1808,9 +1808,10 @@ pymarshal_write_long_to_file(PyObject* self, PyObject *args)
18081808 }
18091809
18101810 PyMarshal_WriteLongToFile (value , fp , version );
1811- assert (!PyErr_Occurred ());
18121811
18131812 fclose (fp );
1813+ if (PyErr_Occurred ())
1814+ return NULL ;
18141815 Py_RETURN_NONE ;
18151816}
18161817
@@ -1833,9 +1834,10 @@ pymarshal_write_object_to_file(PyObject* self, PyObject *args)
18331834 }
18341835
18351836 PyMarshal_WriteObjectToFile (obj , fp , version );
1836- assert (!PyErr_Occurred ());
18371837
18381838 fclose (fp );
1839+ if (PyErr_Occurred ())
1840+ return NULL ;
18391841 Py_RETURN_NONE ;
18401842}
18411843
@@ -1893,46 +1895,48 @@ pymarshal_read_long_from_file(PyObject* self, PyObject *args)
18931895static PyObject *
18941896pymarshal_read_last_object_from_file (PyObject * self , PyObject * args )
18951897{
1898+ PyObject * obj ;
1899+ long pos ;
18961900 PyObject * filename ;
1901+ FILE * fp ;
1902+
18971903 if (!PyArg_ParseTuple (args , "O:pymarshal_read_last_object_from_file" , & filename ))
18981904 return NULL ;
18991905
1900- FILE * fp = _Py_fopen_obj (filename , "rb" );
1906+ fp = _Py_fopen_obj (filename , "rb" );
19011907 if (fp == NULL ) {
19021908 PyErr_SetFromErrno (PyExc_OSError );
19031909 return NULL ;
19041910 }
19051911
1906- PyObject * obj = PyMarshal_ReadLastObjectFromFile (fp );
1907- long pos = ftell (fp );
1912+ obj = PyMarshal_ReadLastObjectFromFile (fp );
1913+ pos = ftell (fp );
19081914
19091915 fclose (fp );
1910- if (obj == NULL ) {
1911- return NULL ;
1912- }
19131916 return Py_BuildValue ("Nl" , obj , pos );
19141917}
19151918
19161919static PyObject *
19171920pymarshal_read_object_from_file (PyObject * self , PyObject * args )
19181921{
1922+ PyObject * obj ;
1923+ long pos ;
19191924 PyObject * filename ;
1925+ FILE * fp ;
1926+
19201927 if (!PyArg_ParseTuple (args , "O:pymarshal_read_object_from_file" , & filename ))
19211928 return NULL ;
19221929
1923- FILE * fp = _Py_fopen_obj (filename , "rb" );
1930+ fp = _Py_fopen_obj (filename , "rb" );
19241931 if (fp == NULL ) {
19251932 PyErr_SetFromErrno (PyExc_OSError );
19261933 return NULL ;
19271934 }
19281935
1929- PyObject * obj = PyMarshal_ReadObjectFromFile (fp );
1930- long pos = ftell (fp );
1936+ obj = PyMarshal_ReadObjectFromFile (fp );
1937+ pos = ftell (fp );
19311938
19321939 fclose (fp );
1933- if (obj == NULL ) {
1934- return NULL ;
1935- }
19361940 return Py_BuildValue ("Nl" , obj , pos );
19371941}
19381942
0 commit comments