summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2011-11-06 19:41:17 (GMT)
committerBrian Curtin <brian@python.org>2011-11-06 19:41:17 (GMT)
commit52fbea1d871c99bad3d6f113cebd01ac9c68d5b9 (patch)
tree1532ea1226432b76942a42344fec4b7c1b8b9944 /Modules
parent9589ab174577773c48492b4e2ad596d4b9c3b120 (diff)
downloadcpython-52fbea1d871c99bad3d6f113cebd01ac9c68d5b9.zip
cpython-52fbea1d871c99bad3d6f113cebd01ac9c68d5b9.tar.gz
cpython-52fbea1d871c99bad3d6f113cebd01ac9c68d5b9.tar.bz2
Fix #13327. Remove the need for an explicit None as the second argument to
os.utime in order to update to the current time. The second argument is now optional.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index f7baad4..2e33022 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -3543,7 +3543,7 @@ static PyObject *
posix_utime(PyObject *self, PyObject *args)
{
#ifdef MS_WINDOWS
- PyObject *arg;
+ PyObject *arg = NULL;
PyObject *obwpath;
wchar_t *wpath = NULL;
PyObject *oapath;
@@ -3554,7 +3554,7 @@ posix_utime(PyObject *self, PyObject *args)
FILETIME atime, mtime;
PyObject *result = NULL;
- if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) {
+ if (PyArg_ParseTuple(args, "U|O:utime", &obwpath, &arg)) {
wpath = PyUnicode_AsUnicode(obwpath);
if (wpath == NULL)
return NULL;
@@ -3571,7 +3571,7 @@ posix_utime(PyObject *self, PyObject *args)
are also valid. */
PyErr_Clear();
- if (!PyArg_ParseTuple(args, "O&O:utime",
+ if (!PyArg_ParseTuple(args, "O&|O:utime",
PyUnicode_FSConverter, &oapath, &arg))
return NULL;
@@ -3589,7 +3589,7 @@ posix_utime(PyObject *self, PyObject *args)
Py_DECREF(oapath);
}
- if (arg == Py_None) {
+ if (!arg || (arg == Py_None)) {
SYSTEMTIME now;
GetSystemTime(&now);
if (!SystemTimeToFileTime(&now, &mtime) ||
@@ -3633,13 +3633,13 @@ done:
time_t atime, mtime;
long ausec, musec;
int res;
- PyObject* arg;
+ PyObject* arg = NULL;
- if (!PyArg_ParseTuple(args, "O&O:utime",
+ if (!PyArg_ParseTuple(args, "O&|O:utime",
PyUnicode_FSConverter, &opath, &arg))
return NULL;
path = PyBytes_AsString(opath);
- if (arg == Py_None) {
+ if (!arg || (arg == Py_None)) {
/* optional time values not given */
Py_BEGIN_ALLOW_THREADS
res = utime(path, NULL);