@@ -4639,10 +4639,9 @@ pymarshal_write_long_to_file(PyObject* self, PyObject *args)
46394639 }
46404640
46414641 PyMarshal_WriteLongToFile (value , fp , version );
4642+ assert (!PyErr_Occurred ());
46424643
46434644 fclose (fp );
4644- if (PyErr_Occurred ())
4645- return NULL ;
46464645 Py_RETURN_NONE ;
46474646}
46484647
@@ -4665,10 +4664,9 @@ pymarshal_write_object_to_file(PyObject* self, PyObject *args)
46654664 }
46664665
46674666 PyMarshal_WriteObjectToFile (obj , fp , version );
4667+ assert (!PyErr_Occurred ());
46684668
46694669 fclose (fp );
4670- if (PyErr_Occurred ())
4671- return NULL ;
46724670 Py_RETURN_NONE ;
46734671}
46744672
@@ -4726,48 +4724,46 @@ pymarshal_read_long_from_file(PyObject* self, PyObject *args)
47264724static PyObject *
47274725pymarshal_read_last_object_from_file (PyObject * self , PyObject * args )
47284726{
4729- PyObject * obj ;
4730- long pos ;
47314727 PyObject * filename ;
4732- FILE * fp ;
4733-
47344728 if (!PyArg_ParseTuple (args , "O:pymarshal_read_last_object_from_file" , & filename ))
47354729 return NULL ;
47364730
4737- fp = _Py_fopen_obj (filename , "rb" );
4731+ FILE * fp = _Py_fopen_obj (filename , "rb" );
47384732 if (fp == NULL ) {
47394733 PyErr_SetFromErrno (PyExc_OSError );
47404734 return NULL ;
47414735 }
47424736
4743- obj = PyMarshal_ReadLastObjectFromFile (fp );
4744- pos = ftell (fp );
4737+ PyObject * obj = PyMarshal_ReadLastObjectFromFile (fp );
4738+ long pos = ftell (fp );
47454739
47464740 fclose (fp );
4741+ if (obj == NULL ) {
4742+ return NULL ;
4743+ }
47474744 return Py_BuildValue ("Nl" , obj , pos );
47484745}
47494746
47504747static PyObject *
47514748pymarshal_read_object_from_file (PyObject * self , PyObject * args )
47524749{
4753- PyObject * obj ;
4754- long pos ;
47554750 PyObject * filename ;
4756- FILE * fp ;
4757-
47584751 if (!PyArg_ParseTuple (args , "O:pymarshal_read_object_from_file" , & filename ))
47594752 return NULL ;
47604753
4761- fp = _Py_fopen_obj (filename , "rb" );
4754+ FILE * fp = _Py_fopen_obj (filename , "rb" );
47624755 if (fp == NULL ) {
47634756 PyErr_SetFromErrno (PyExc_OSError );
47644757 return NULL ;
47654758 }
47664759
4767- obj = PyMarshal_ReadObjectFromFile (fp );
4768- pos = ftell (fp );
4760+ PyObject * obj = PyMarshal_ReadObjectFromFile (fp );
4761+ long pos = ftell (fp );
47694762
47704763 fclose (fp );
4764+ if (obj == NULL ) {
4765+ return NULL ;
4766+ }
47714767 return Py_BuildValue ("Nl" , obj , pos );
47724768}
47734769
0 commit comments