summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2011-11-07 22:09:20 (GMT)
committerBrian Curtin <brian@python.org>2011-11-07 22:09:20 (GMT)
commit569b49432002a4750640c4b3883187796f2f5036 (patch)
treeac72250d790f11695d9aa8b30ec7c374359a60a2 /Modules/posixmodule.c
parent7ef53ef916453fc2d907ae783aa0bd5801aa5575 (diff)
downloadcpython-569b49432002a4750640c4b3883187796f2f5036.zip
cpython-569b49432002a4750640c4b3883187796f2f5036.tar.gz
cpython-569b49432002a4750640c4b3883187796f2f5036.tar.bz2
Fix #13327. utimensat now has the atime and mtime arguments set as optional,
defaulting to None like the other utimes family members. It now accepts keyword arguments because, unlike other other functions in the family, it has a `flags` value at the end of the argument list (which retains its 0 default).
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index da42f3a..49d1182 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -10019,12 +10019,13 @@ posix_unlinkat(PyObject *self, PyObject *args)
#ifdef HAVE_UTIMENSAT
PyDoc_STRVAR(posix_utimensat__doc__,
-"utimensat(dirfd, path, (atime_sec, atime_nsec),\n\
- (mtime_sec, mtime_nsec), flags)\n\
+"utimensat(dirfd, path[, atime=(atime_sec, atime_nsec),\n\
+ mtime=(mtime_sec, mtime_nsec), flags=0])\n\
utimensat(dirfd, path, None, None, flags)\n\n\
Updates the timestamps of a file with nanosecond precision. If path is\n\
relative, it is taken as relative to dirfd.\n\
-The second form sets atime and mtime to the current time.\n\
+If atime and mtime are both None, which is the default, set atime and\n\
+mtime to the current time.\n\
flags is optional and may be 0 or AT_SYMLINK_NOFOLLOW.\n\
If path is relative and dirfd is the special value AT_FDCWD, then path\n\
is interpreted relative to the current working directory.\n\
@@ -10033,16 +10034,19 @@ current time.\n\
If *_nsec is specified as UTIME_OMIT, the timestamp is not updated.");
static PyObject *
-posix_utimensat(PyObject *self, PyObject *args)
+posix_utimensat(PyObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *opath;
char *path;
int res, dirfd, flags = 0;
- PyObject *atime, *mtime;
+ PyObject *atime = Py_None;
+ PyObject *mtime = Py_None;
+
+ static char *kwlist[] = {"dirfd", "path", "atime", "mtime", "flags", NULL};
struct timespec buf[2];
- if (!PyArg_ParseTuple(args, "iO&OO|i:utimensat",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO&|OOi:utimensat", kwlist,
&dirfd, PyUnicode_FSConverter, &opath, &atime, &mtime, &flags))
return NULL;
path = PyBytes_AsString(opath);
@@ -10939,7 +10943,8 @@ static PyMethodDef posix_methods[] = {
{"unlinkat", posix_unlinkat, METH_VARARGS, posix_unlinkat__doc__},
#endif
#ifdef HAVE_UTIMENSAT
- {"utimensat", posix_utimensat, METH_VARARGS, posix_utimensat__doc__},
+ {"utimensat", posix_utimensat, METH_VARARGS | METH_KEYWORDS,
+ posix_utimensat__doc__},
#endif
#ifdef HAVE_MKFIFOAT
{"mkfifoat", posix_mkfifoat, METH_VARARGS, posix_mkfifoat__doc__},