@@ -256,11 +256,8 @@ file_seek(f, args)
256256 if (f -> f_fp == NULL )
257257 return err_closed ();
258258 whence = 0 ;
259- if (!PyArg_Parse (args , "l" , & offset )) {
260- PyErr_Clear ();
261- if (!PyArg_Parse (args , "(li)" , & offset , & whence ))
262- return NULL ;
263- }
259+ if (!PyArg_ParseTuple (args , "l|i" , & offset , & whence ))
260+ return NULL ;
264261 Py_BEGIN_ALLOW_THREADS
265262 errno = 0 ;
266263 ret = fseek (f -> f_fp , offset , whence );
@@ -285,10 +282,11 @@ file_truncate(f, args)
285282
286283 if (f -> f_fp == NULL )
287284 return err_closed ();
288- if (!PyArg_Parse (args , "l" , & newsize )) {
289- PyErr_Clear ();
290- if (!PyArg_NoArgs (args ))
291- return NULL ;
285+ newsize = -1 ;
286+ if (!PyArg_ParseTuple (args , "|l" , & newsize )) {
287+ return NULL ;
288+ }
289+ if (newsize < 0 ) {
292290 Py_BEGIN_ALLOW_THREADS
293291 errno = 0 ;
294292 newsize = ftell (f -> f_fp ); /* default to current position*/
@@ -870,9 +868,9 @@ static PyMethodDef file_methods[] = {
870868 {"read" , (PyCFunction )file_read , 1 },
871869 {"write" , (PyCFunction )file_write , 0 },
872870 {"fileno" , (PyCFunction )file_fileno , 0 },
873- {"seek" , (PyCFunction )file_seek , 0 },
871+ {"seek" , (PyCFunction )file_seek , 1 },
874872#ifdef HAVE_FTRUNCATE
875- {"truncate" , (PyCFunction )file_truncate , 0 },
873+ {"truncate" , (PyCFunction )file_truncate , 1 },
876874#endif
877875 {"tell" , (PyCFunction )file_tell , 0 },
878876 {"readinto" , (PyCFunction )file_readinto , 0 },
0 commit comments