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