@@ -1808,10 +1808,9 @@ pymarshal_write_long_to_file(PyObject* self, PyObject *args)
1808
1808
}
1809
1809
1810
1810
PyMarshal_WriteLongToFile (value , fp , version );
1811
+ assert (!PyErr_Occurred ());
1811
1812
1812
1813
fclose (fp );
1813
- if (PyErr_Occurred ())
1814
- return NULL ;
1815
1814
Py_RETURN_NONE ;
1816
1815
}
1817
1816
@@ -1834,10 +1833,9 @@ pymarshal_write_object_to_file(PyObject* self, PyObject *args)
1834
1833
}
1835
1834
1836
1835
PyMarshal_WriteObjectToFile (obj , fp , version );
1836
+ assert (!PyErr_Occurred ());
1837
1837
1838
1838
fclose (fp );
1839
- if (PyErr_Occurred ())
1840
- return NULL ;
1841
1839
Py_RETURN_NONE ;
1842
1840
}
1843
1841
@@ -1895,48 +1893,46 @@ pymarshal_read_long_from_file(PyObject* self, PyObject *args)
1895
1893
static PyObject *
1896
1894
pymarshal_read_last_object_from_file (PyObject * self , PyObject * args )
1897
1895
{
1898
- PyObject * obj ;
1899
- long pos ;
1900
1896
PyObject * filename ;
1901
- FILE * fp ;
1902
-
1903
1897
if (!PyArg_ParseTuple (args , "O:pymarshal_read_last_object_from_file" , & filename ))
1904
1898
return NULL ;
1905
1899
1906
- fp = _Py_fopen_obj (filename , "rb" );
1900
+ FILE * fp = _Py_fopen_obj (filename , "rb" );
1907
1901
if (fp == NULL ) {
1908
1902
PyErr_SetFromErrno (PyExc_OSError );
1909
1903
return NULL ;
1910
1904
}
1911
1905
1912
- obj = PyMarshal_ReadLastObjectFromFile (fp );
1913
- pos = ftell (fp );
1906
+ PyObject * obj = PyMarshal_ReadLastObjectFromFile (fp );
1907
+ long pos = ftell (fp );
1914
1908
1915
1909
fclose (fp );
1910
+ if (obj == NULL ) {
1911
+ return NULL ;
1912
+ }
1916
1913
return Py_BuildValue ("Nl" , obj , pos );
1917
1914
}
1918
1915
1919
1916
static PyObject *
1920
1917
pymarshal_read_object_from_file (PyObject * self , PyObject * args )
1921
1918
{
1922
- PyObject * obj ;
1923
- long pos ;
1924
1919
PyObject * filename ;
1925
- FILE * fp ;
1926
-
1927
1920
if (!PyArg_ParseTuple (args , "O:pymarshal_read_object_from_file" , & filename ))
1928
1921
return NULL ;
1929
1922
1930
- fp = _Py_fopen_obj (filename , "rb" );
1923
+ FILE * fp = _Py_fopen_obj (filename , "rb" );
1931
1924
if (fp == NULL ) {
1932
1925
PyErr_SetFromErrno (PyExc_OSError );
1933
1926
return NULL ;
1934
1927
}
1935
1928
1936
- obj = PyMarshal_ReadObjectFromFile (fp );
1937
- pos = ftell (fp );
1929
+ PyObject * obj = PyMarshal_ReadObjectFromFile (fp );
1930
+ long pos = ftell (fp );
1938
1931
1939
1932
fclose (fp );
1933
+ if (obj == NULL ) {
1934
+ return NULL ;
1935
+ }
1940
1936
return Py_BuildValue ("Nl" , obj , pos );
1941
1937
}
1942
1938
0 commit comments