mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Fix 13327. Remove explicit None arguments from futimes, futimens, futimesat,
and lutimes.
This commit is contained in:
parent
b0d5b5d3b2
commit
c1b65d1831
3 changed files with 27 additions and 28 deletions
|
|
@ -872,8 +872,7 @@ as internal buffering of data.
|
|||
.. versionadded:: 3.3
|
||||
|
||||
|
||||
.. function:: futimesat(dirfd, path, (atime, mtime))
|
||||
futimesat(dirfd, path, None)
|
||||
.. function:: futimesat(dirfd, path[, (atime, mtime)])
|
||||
|
||||
Like :func:`utime` but if *path* is relative, it is taken as relative to *dirfd*.
|
||||
If *path* is relative and *dirfd* is the special value :data:`AT_FDCWD`, then *path*
|
||||
|
|
@ -884,12 +883,11 @@ as internal buffering of data.
|
|||
.. versionadded:: 3.3
|
||||
|
||||
|
||||
.. function:: futimens(fd, (atime_sec, atime_nsec), (mtime_sec, mtime_nsec))
|
||||
futimens(fd, None, None)
|
||||
.. function:: futimens(fd[, (atime_sec, atime_nsec), (mtime_sec, mtime_nsec)])
|
||||
|
||||
Updates the timestamps of a file specified by the file descriptor *fd*, with
|
||||
nanosecond precision.
|
||||
The second form sets *atime* and *mtime* to the current time.
|
||||
If no second argument is given, set *atime* and *mtime* to the current time.
|
||||
If *atime_nsec* or *mtime_nsec* is specified as :data:`UTIME_NOW`, the corresponding
|
||||
timestamp is updated to the current time.
|
||||
If *atime_nsec* or *mtime_nsec* is specified as :data:`UTIME_OMIT`, the corresponding
|
||||
|
|
@ -911,11 +909,10 @@ as internal buffering of data.
|
|||
.. versionadded:: 3.3
|
||||
|
||||
|
||||
.. function:: futimes(fd, (atime, mtime))
|
||||
futimes(fd, None)
|
||||
.. function:: futimes(fd[, (atime, mtime)])
|
||||
|
||||
Set the access and modified time of the file specified by the file
|
||||
descriptor *fd* to the given values. If the second form is used, set the
|
||||
descriptor *fd* to the given values. If no second argument is used, set the
|
||||
access and modified times to the current time.
|
||||
|
||||
Availability: Unix.
|
||||
|
|
@ -1702,8 +1699,7 @@ Files and Directories
|
|||
Added support for Windows 6.0 (Vista) symbolic links.
|
||||
|
||||
|
||||
.. function:: lutimes(path, (atime, mtime))
|
||||
lutimes(path, None)
|
||||
.. function:: lutimes(path[, (atime, mtime)])
|
||||
|
||||
Like :func:`utime`, but if *path* is a symbolic link, it is not
|
||||
dereferenced.
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ class PosixTester(unittest.TestCase):
|
|||
fd = os.open(support.TESTFN, os.O_RDONLY)
|
||||
try:
|
||||
posix.futimes(fd, None)
|
||||
posix.futimes(fd)
|
||||
self.assertRaises(TypeError, posix.futimes, fd, (None, None))
|
||||
self.assertRaises(TypeError, posix.futimes, fd, (now, None))
|
||||
self.assertRaises(TypeError, posix.futimes, fd, (None, now))
|
||||
|
|
@ -252,6 +253,7 @@ class PosixTester(unittest.TestCase):
|
|||
self.assertRaises(TypeError, posix.lutimes, support.TESTFN, (None, now))
|
||||
posix.lutimes(support.TESTFN, (int(now), int(now)))
|
||||
posix.lutimes(support.TESTFN, (now, now))
|
||||
posix.lutimes(support.TESTFN)
|
||||
|
||||
@unittest.skipUnless(hasattr(posix, 'futimens'), "test needs posix.futimens()")
|
||||
def test_futimens(self):
|
||||
|
|
@ -263,6 +265,7 @@ class PosixTester(unittest.TestCase):
|
|||
self.assertRaises(TypeError, posix.futimens, fd, None, (now, 0))
|
||||
posix.futimens(fd, (int(now), int((now - int(now)) * 1e9)),
|
||||
(int(now), int((now - int(now)) * 1e9)))
|
||||
posix.futimens(fd)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
|
|
@ -691,6 +694,7 @@ class PosixTester(unittest.TestCase):
|
|||
try:
|
||||
now = time.time()
|
||||
posix.futimesat(f, support.TESTFN, None)
|
||||
posix.futimesat(f, support.TESTFN)
|
||||
self.assertRaises(TypeError, posix.futimesat, f, support.TESTFN, (None, None))
|
||||
self.assertRaises(TypeError, posix.futimesat, f, support.TESTFN, (now, None))
|
||||
self.assertRaises(TypeError, posix.futimesat, f, support.TESTFN, (None, now))
|
||||
|
|
|
|||
|
|
@ -3534,10 +3534,10 @@ extract_time(PyObject *t, time_t* sec, long* usec)
|
|||
}
|
||||
|
||||
PyDoc_STRVAR(posix_utime__doc__,
|
||||
"utime(path, (atime, mtime))\n\
|
||||
utime(path, None)\n\n\
|
||||
Set the access and modified time of the file to the given values. If the\n\
|
||||
second form is used, set the access and modified times to the current time.");
|
||||
"utime(path[, (atime, mtime)])\n\
|
||||
Set the access and modified time of the file to the given values.\n\
|
||||
If no second argument is used, set the access and modified times to\n\
|
||||
the current time.");
|
||||
|
||||
static PyObject *
|
||||
posix_utime(PyObject *self, PyObject *args)
|
||||
|
|
@ -3706,21 +3706,20 @@ done:
|
|||
|
||||
#ifdef HAVE_FUTIMES
|
||||
PyDoc_STRVAR(posix_futimes__doc__,
|
||||
"futimes(fd, (atime, mtime))\n\
|
||||
futimes(fd, None)\n\n\
|
||||
"futimes(fd[, (atime, mtime)])\n\
|
||||
Set the access and modified time of the file specified by the file\n\
|
||||
descriptor fd to the given values. If the second form is used, set the\n\
|
||||
descriptor fd to the given values. If no second argument is used, set the\n\
|
||||
access and modified times to the current time.");
|
||||
|
||||
static PyObject *
|
||||
posix_futimes(PyObject *self, PyObject *args)
|
||||
{
|
||||
int res, fd;
|
||||
PyObject* arg;
|
||||
PyObject* arg = Py_None;
|
||||
time_t atime, mtime;
|
||||
long ausec, musec;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iO:futimes", &fd, &arg))
|
||||
if (!PyArg_ParseTuple(args, "i|O:futimes", &fd, &arg))
|
||||
return NULL;
|
||||
|
||||
if (arg == Py_None) {
|
||||
|
|
@ -3771,20 +3770,20 @@ posix_futimes(PyObject *self, PyObject *args)
|
|||
|
||||
#ifdef HAVE_LUTIMES
|
||||
PyDoc_STRVAR(posix_lutimes__doc__,
|
||||
"lutimes(path, (atime, mtime))\n\
|
||||
lutimes(path, None)\n\n\
|
||||
"lutimes(path[, (atime, mtime)])\n\
|
||||
Like utime(), but if path is a symbolic link, it is not dereferenced.");
|
||||
|
||||
static PyObject *
|
||||
posix_lutimes(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *opath, *arg;
|
||||
PyObject *opath;
|
||||
PyObject *arg = Py_None;
|
||||
const char *path;
|
||||
int res;
|
||||
time_t atime, mtime;
|
||||
long ausec, musec;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O&O:lutimes",
|
||||
if (!PyArg_ParseTuple(args, "O&|O:lutimes",
|
||||
PyUnicode_FSConverter, &opath, &arg))
|
||||
return NULL;
|
||||
path = PyBytes_AsString(opath);
|
||||
|
|
@ -3840,11 +3839,10 @@ posix_lutimes(PyObject *self, PyObject *args)
|
|||
|
||||
#ifdef HAVE_FUTIMENS
|
||||
PyDoc_STRVAR(posix_futimens__doc__,
|
||||
"futimens(fd, (atime_sec, atime_nsec), (mtime_sec, mtime_nsec))\n\
|
||||
futimens(fd, None, None)\n\n\
|
||||
"futimens(fd[, (atime_sec, atime_nsec), (mtime_sec, mtime_nsec)])\n\
|
||||
Updates the timestamps of a file specified by the file descriptor fd, with\n\
|
||||
nanosecond precision.\n\
|
||||
The second form sets atime and mtime to the current time.\n\
|
||||
If no second argument is given, set atime and mtime to the current time.\n\
|
||||
If *_nsec is specified as UTIME_NOW, the timestamp is updated to the\n\
|
||||
current time.\n\
|
||||
If *_nsec is specified as UTIME_OMIT, the timestamp is not updated.");
|
||||
|
|
@ -3853,10 +3851,11 @@ static PyObject *
|
|||
posix_futimens(PyObject *self, PyObject *args)
|
||||
{
|
||||
int res, fd;
|
||||
PyObject *atime, *mtime;
|
||||
PyObject *atime = Py_None;
|
||||
PyObject *mtime = Py_None;
|
||||
struct timespec buf[2];
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iOO:futimens",
|
||||
if (!PyArg_ParseTuple(args, "i|OO:futimens",
|
||||
&fd, &atime, &mtime))
|
||||
return NULL;
|
||||
if (atime == Py_None && mtime == Py_None) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue