Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44328e6

Browse files
author
Fredrik Lundh
committed
-- get rid of a compiler warning on unix. (as reported
for #100836, but implemented in a different way)
1 parent 1bbddd0 commit 44328e6

1 file changed

Lines changed: 13 additions & 21 deletions

File tree

Modules/posixmodule.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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
772753
static char posix_chown__doc__[] =
773754
"chown(path, uid, gid) -> None\n\
774755
Change the owner and group id of path to the numeric uid and gid.";
775756

776757
static PyObject *
777758
posix_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

Comments
 (0)