Merged revisions 59239-59244 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59240 | amaury.forgeotdarc | 2007-11-30 21:37:22 +0100 (Fri, 30 Nov 2007) | 2 lines Add a NEWS entry for r59231 ........ r59241 | amaury.forgeotdarc | 2007-11-30 21:51:40 +0100 (Fri, 30 Nov 2007) | 5 lines Issue #1521: on 64bit platforms, str.decode fails on very long strings. The t# and w# formats were not correctly handled. Will backport. ........ r59242 | christian.heimes | 2007-11-30 22:11:28 +0100 (Fri, 30 Nov 2007) | 3 lines Fix for feature request #1528 Add os.fchmod Georg Brandl has added fchmod() and fchown(). I've contributed lchown but I'm not able to test it on Linux. However it should be available on Mac and some other flavors of Unix. I've made a quick test of fchmod() and fchown() on my system. They are working as expected. ........
This commit is contained in:
parent
04a4eb3405
commit
4e30a845b4
|
@ -417,6 +417,19 @@ by file descriptors.
|
|||
Availability: Macintosh, Unix, Windows.
|
||||
|
||||
|
||||
.. function:: fchmod(fd, mode)
|
||||
|
||||
Change the mode of the file given by *fd* to the numeric *mode*. See the docs
|
||||
for :func:`chmod` for possible values of *mode*. Availability: Unix.
|
||||
|
||||
|
||||
.. function:: fchown(fd, uid, gid)
|
||||
|
||||
Change the owner and group id of the file given by *fd* to the numeric *uid*
|
||||
and *gid*. To leave one of the ids unchanged, set it to -1.
|
||||
Availability: Unix.
|
||||
|
||||
|
||||
.. function:: fdatasync(fd)
|
||||
|
||||
Force write of file with filedescriptor *fd* to disk. Does not force update of
|
||||
|
@ -475,6 +488,13 @@ by file descriptors.
|
|||
tty(-like) device, else ``False``. Availability: Macintosh, Unix.
|
||||
|
||||
|
||||
.. function:: lchmod(path, mode)
|
||||
|
||||
Change the mode of *path* to the numeric *mode*. If path is a symlink, this
|
||||
affects the symlink rather than the target. See the docs for :func:`chmod`
|
||||
for possible values of *mode*. Availability: Unix.
|
||||
|
||||
|
||||
.. function:: lseek(fd, pos, how)
|
||||
|
||||
Set the current position of file descriptor *fd* to position *pos*, modified by
|
||||
|
|
|
@ -64,13 +64,15 @@ class StrTest(unittest.TestCase):
|
|||
self.assertEquals(s.count('i'), 1)
|
||||
self.assertEquals(s.count('j'), 0)
|
||||
|
||||
@bigmemtest(minsize=0, memuse=1)
|
||||
@bigmemtest(minsize=_2G + 2, memuse=3)
|
||||
def test_decode(self, size):
|
||||
pass
|
||||
s = '.' * size
|
||||
self.assertEquals(len(s.decode('utf-8')), size)
|
||||
|
||||
@bigmemtest(minsize=0, memuse=1)
|
||||
@bigmemtest(minsize=_2G + 2, memuse=3)
|
||||
def test_encode(self, size):
|
||||
pass
|
||||
s = u'.' * size
|
||||
self.assertEquals(len(s.encode('utf-8')), size)
|
||||
|
||||
@bigmemtest(minsize=_2G, memuse=2)
|
||||
def test_endswith(self, size):
|
||||
|
|
|
@ -186,6 +186,12 @@ extern int chmod(const char *, int);
|
|||
#else
|
||||
extern int chmod(const char *, mode_t);
|
||||
#endif
|
||||
/*#ifdef HAVE_FCHMOD
|
||||
extern int fchmod(int, mode_t);
|
||||
#endif*/
|
||||
/*#ifdef HAVE_LCHMOD
|
||||
extern int lchmod(const char *, mode_t);
|
||||
#endif*/
|
||||
extern int chown(const char *, uid_t, gid_t);
|
||||
extern char *getcwd(char *, int);
|
||||
extern char *strerror(int);
|
||||
|
@ -1747,6 +1753,52 @@ posix_chmod(PyObject *self, PyObject *args)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_FCHMOD
|
||||
PyDoc_STRVAR(posix_fchmod__doc__,
|
||||
"fchmod(fd, mode)\n\n\
|
||||
Change the access permissions of the file given by file\n\
|
||||
descriptor fd.");
|
||||
|
||||
static PyObject *
|
||||
posix_fchmod(PyObject *self, PyObject *args)
|
||||
{
|
||||
int fd, mode, res;
|
||||
if (!PyArg_ParseTuple(args, "ii:fchmod", &fd, &mode))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = fchmod(fd, mode);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return posix_error();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#endif /* HAVE_FCHMOD */
|
||||
|
||||
#ifdef HAVE_LCHMOD
|
||||
PyDoc_STRVAR(posix_lchmod__doc__,
|
||||
"lchmod(path, mode)\n\n\
|
||||
Change the access permissions of a file. If path is a symlink, this\n\
|
||||
affects the link itself rather than the target.");
|
||||
|
||||
static PyObject *
|
||||
posix_lchmod(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *path = NULL;
|
||||
int i;
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, "eti:lchmod", Py_FileSystemDefaultEncoding,
|
||||
&path, &i))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = lchmod(path, i);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return posix_error_with_allocated_filename(path);
|
||||
PyMem_Free(path);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#endif /* HAVE_LCHMOD */
|
||||
|
||||
|
||||
#ifdef HAVE_CHFLAGS
|
||||
PyDoc_STRVAR(posix_chflags__doc__,
|
||||
|
@ -1868,6 +1920,28 @@ posix_chown(PyObject *self, PyObject *args)
|
|||
}
|
||||
#endif /* HAVE_CHOWN */
|
||||
|
||||
#ifdef HAVE_FCHOWN
|
||||
PyDoc_STRVAR(posix_fchown__doc__,
|
||||
"fchown(fd, uid, gid)\n\n\
|
||||
Change the owner and group id of the file given by file descriptor\n\
|
||||
fd to the numeric uid and gid.");
|
||||
|
||||
static PyObject *
|
||||
posix_fchown(PyObject *self, PyObject *args)
|
||||
{
|
||||
int fd, uid, gid;
|
||||
int res;
|
||||
if (!PyArg_ParseTuple(args, "iii:chown", &fd, &uid, &gid))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = fchown(fd, (uid_t) uid, (gid_t) gid);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (res < 0)
|
||||
return posix_error();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#endif /* HAVE_FCHOWN */
|
||||
|
||||
#ifdef HAVE_LCHOWN
|
||||
PyDoc_STRVAR(posix_lchown__doc__,
|
||||
"lchown(path, uid, gid)\n\n\
|
||||
|
@ -6664,9 +6738,18 @@ static PyMethodDef posix_methods[] = {
|
|||
{"chflags", posix_chflags, METH_VARARGS, posix_chflags__doc__},
|
||||
#endif /* HAVE_CHFLAGS */
|
||||
{"chmod", posix_chmod, METH_VARARGS, posix_chmod__doc__},
|
||||
#ifdef HAVE_FCHMOD
|
||||
{"fchmod", posix_fchmod, METH_VARARGS, posix_fchmod__doc__},
|
||||
#endif /* HAVE_FCHMOD */
|
||||
#ifdef HAVE_CHOWN
|
||||
{"chown", posix_chown, METH_VARARGS, posix_chown__doc__},
|
||||
#endif /* HAVE_CHOWN */
|
||||
#ifdef HAVE_LCHMOD
|
||||
{"lchmod", posix_lchmod, METH_VARARGS, posix_lchmod__doc__},
|
||||
#endif /* HAVE_LCHMOD */
|
||||
#ifdef HAVE_FCHOWN
|
||||
{"fchown", posix_fchown, METH_VARARGS, posix_fchown__doc__},
|
||||
#endif /* HAVE_FCHOWN */
|
||||
#ifdef HAVE_LCHFLAGS
|
||||
{"lchflags", posix_lchflags, METH_VARARGS, posix_lchflags__doc__},
|
||||
#endif /* HAVE_LCHFLAGS */
|
||||
|
|
|
@ -1182,7 +1182,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
case 'w': { /* memory buffer, read-write access */
|
||||
void **p = va_arg(*p_va, void **);
|
||||
PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
|
||||
int count;
|
||||
Py_ssize_t count;
|
||||
int temp=-1;
|
||||
Py_buffer view;
|
||||
|
||||
|
@ -1216,7 +1216,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
case 't': { /* 8-bit character buffer, read-only access */
|
||||
char **p = va_arg(*p_va, char **);
|
||||
PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
|
||||
int count;
|
||||
Py_ssize_t count;
|
||||
Py_buffer view;
|
||||
|
||||
if (*format++ != '#')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#! /bin/sh
|
||||
# From configure.in Revision: 58054 .
|
||||
# From configure.in Revision: 58817 .
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.61 for python 3.0.
|
||||
#
|
||||
|
@ -15436,15 +15436,18 @@ echo "${ECHO_T}MACHDEP_OBJS" >&6; }
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for ac_func in alarm bind_textdomain_codeset chflags chown clock confstr \
|
||||
ctermid execv fork fpathconf ftime ftruncate \
|
||||
ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
|
||||
gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
|
||||
getpriority getpwent getspnam getspent getsid getwd \
|
||||
kill killpg lchflags lchown lstat mkfifo mknod mktime \
|
||||
kill killpg lchflags lchmod lchown lstat mkfifo mknod mktime \
|
||||
mremap nice pathconf pause plock poll pthread_init \
|
||||
putenv readlink realpath \
|
||||
select setegid seteuid setgid \
|
||||
|
|
|
@ -2275,10 +2275,10 @@ AC_MSG_RESULT(MACHDEP_OBJS)
|
|||
|
||||
# checks for library functions
|
||||
AC_CHECK_FUNCS(alarm bind_textdomain_codeset chflags chown clock confstr \
|
||||
ctermid execv fork fpathconf ftime ftruncate \
|
||||
ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
|
||||
gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
|
||||
getpriority getpwent getspnam getspent getsid getwd \
|
||||
kill killpg lchflags lchown lstat mkfifo mknod mktime \
|
||||
kill killpg lchflags lchmod lchown lstat mkfifo mknod mktime \
|
||||
mremap nice pathconf pause plock poll pthread_init \
|
||||
putenv readlink realpath \
|
||||
select setegid seteuid setgid \
|
||||
|
|
|
@ -141,6 +141,12 @@
|
|||
/* Define if you have the 'fchdir' function. */
|
||||
#undef HAVE_FCHDIR
|
||||
|
||||
/* Define to 1 if you have the `fchmod' function. */
|
||||
#undef HAVE_FCHMOD
|
||||
|
||||
/* Define to 1 if you have the `fchown' function. */
|
||||
#undef HAVE_FCHOWN
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
|
@ -297,6 +303,9 @@
|
|||
/* Define to 1 if you have the `lchflags' function. */
|
||||
#undef HAVE_LCHFLAGS
|
||||
|
||||
/* Define to 1 if you have the `lchmod' function. */
|
||||
#undef HAVE_LCHMOD
|
||||
|
||||
/* Define to 1 if you have the `lchown' function. */
|
||||
#undef HAVE_LCHOWN
|
||||
|
||||
|
|
Loading…
Reference in New Issue