@@ -512,25 +512,6 @@ posix_strint(PyObject *args, char *format, int (*func)(const char *, int))
512512 return Py_None ;
513513}
514514
515- static PyObject *
516- posix_strintint (PyObject * args , char * format ,
517- int (* func )(const char * , int , int ))
518- {
519- char * path ;
520- int i ,i2 ;
521- int res ;
522- if (!PyArg_ParseTuple (args , format , & path , & i , & i2 ))
523- return NULL ;
524- Py_BEGIN_ALLOW_THREADS
525- res = (* func )(path , i , i2 );
526- Py_END_ALLOW_THREADS
527- if (res < 0 )
528- return posix_error_with_filename (path );
529- Py_INCREF (Py_None );
530- return Py_None ;
531- }
532-
533-
534515
535516/* pack a system stat C structure into the Python stat tuple
536517 (used by posix_stat() and posix_fstat()) */
@@ -768,15 +749,26 @@ posix_fdatasync(PyObject *self, PyObject *args)
768749#endif /* HAVE_FDATASYNC */
769750
770751
771- #ifdef HAVE_CHOWN
752+ #if HAVE_CHOWN
772753static char posix_chown__doc__ [] =
773754"chown(path, uid, gid) -> None\n\
774755Change the owner and group id of path to the numeric uid and gid." ;
775756
776757static PyObject *
777758posix_chown (PyObject * self , PyObject * args )
778759{
779- return posix_strintint (args , "sii:chown" , chown );
760+ char * path ;
761+ int uid , gid ;
762+ int res ;
763+ if (!PyArg_ParseTuple (args , "sii:chown" , & path , & uid , & gid ))
764+ return NULL ;
765+ Py_BEGIN_ALLOW_THREADS
766+ res = chown (path , (uid_t ) uid , (gid_t ) gid );
767+ Py_END_ALLOW_THREADS
768+ if (res < 0 )
769+ return posix_error_with_filename (path );
770+ Py_INCREF (Py_None );
771+ return Py_None ;
780772}
781773#endif /* HAVE_CHOWN */
782774
0 commit comments