@@ -4639,10 +4639,9 @@ pymarshal_write_long_to_file(PyObject* self, PyObject *args)
4639
4639
}
4640
4640
4641
4641
PyMarshal_WriteLongToFile (value , fp , version );
4642
+ assert (!PyErr_Occurred ());
4642
4643
4643
4644
fclose (fp );
4644
- if (PyErr_Occurred ())
4645
- return NULL ;
4646
4645
Py_RETURN_NONE ;
4647
4646
}
4648
4647
@@ -4665,10 +4664,9 @@ pymarshal_write_object_to_file(PyObject* self, PyObject *args)
4665
4664
}
4666
4665
4667
4666
PyMarshal_WriteObjectToFile (obj , fp , version );
4667
+ assert (!PyErr_Occurred ());
4668
4668
4669
4669
fclose (fp );
4670
- if (PyErr_Occurred ())
4671
- return NULL ;
4672
4670
Py_RETURN_NONE ;
4673
4671
}
4674
4672
@@ -4726,48 +4724,46 @@ pymarshal_read_long_from_file(PyObject* self, PyObject *args)
4726
4724
static PyObject *
4727
4725
pymarshal_read_last_object_from_file (PyObject * self , PyObject * args )
4728
4726
{
4729
- PyObject * obj ;
4730
- long pos ;
4731
4727
PyObject * filename ;
4732
- FILE * fp ;
4733
-
4734
4728
if (!PyArg_ParseTuple (args , "O:pymarshal_read_last_object_from_file" , & filename ))
4735
4729
return NULL ;
4736
4730
4737
- fp = _Py_fopen_obj (filename , "rb" );
4731
+ FILE * fp = _Py_fopen_obj (filename , "rb" );
4738
4732
if (fp == NULL ) {
4739
4733
PyErr_SetFromErrno (PyExc_OSError );
4740
4734
return NULL ;
4741
4735
}
4742
4736
4743
- obj = PyMarshal_ReadLastObjectFromFile (fp );
4744
- pos = ftell (fp );
4737
+ PyObject * obj = PyMarshal_ReadLastObjectFromFile (fp );
4738
+ long pos = ftell (fp );
4745
4739
4746
4740
fclose (fp );
4741
+ if (obj == NULL ) {
4742
+ return NULL ;
4743
+ }
4747
4744
return Py_BuildValue ("Nl" , obj , pos );
4748
4745
}
4749
4746
4750
4747
static PyObject *
4751
4748
pymarshal_read_object_from_file (PyObject * self , PyObject * args )
4752
4749
{
4753
- PyObject * obj ;
4754
- long pos ;
4755
4750
PyObject * filename ;
4756
- FILE * fp ;
4757
-
4758
4751
if (!PyArg_ParseTuple (args , "O:pymarshal_read_object_from_file" , & filename ))
4759
4752
return NULL ;
4760
4753
4761
- fp = _Py_fopen_obj (filename , "rb" );
4754
+ FILE * fp = _Py_fopen_obj (filename , "rb" );
4762
4755
if (fp == NULL ) {
4763
4756
PyErr_SetFromErrno (PyExc_OSError );
4764
4757
return NULL ;
4765
4758
}
4766
4759
4767
- obj = PyMarshal_ReadObjectFromFile (fp );
4768
- pos = ftell (fp );
4760
+ PyObject * obj = PyMarshal_ReadObjectFromFile (fp );
4761
+ long pos = ftell (fp );
4769
4762
4770
4763
fclose (fp );
4764
+ if (obj == NULL ) {
4765
+ return NULL ;
4766
+ }
4771
4767
return Py_BuildValue ("Nl" , obj , pos );
4772
4768
}
4773
4769
0 commit comments