diff -r 416cd57d38cf Lib/test/test_os.py --- a/Lib/test/test_os.py Sun Jul 15 00:38:43 2012 +1000 +++ b/Lib/test/test_os.py Tue Jul 17 18:19:05 2012 -0500 @@ -355,6 +355,13 @@ os.utime in os.supports_follow_symlinks, "follow_symlinks support for utime required for this test.") + def test_utime_ns_none(self): + # Issue 15382 - ns=None ought to be given explicitly without error + os.utime(self.fname, ns=None) + os.utime(self.fname, times=None, ns=None) + os.utime(self.fname, times=(1000, 1000), ns=None) + + @requires_utime_nofollow_symlinks def test_lutimes_ns(self): def lutimes_ns(file, times): diff -r 416cd57d38cf Modules/posixmodule.c --- a/Modules/posixmodule.c Sun Jul 15 00:38:43 2012 +1000 +++ b/Modules/posixmodule.c Tue Jul 17 18:19:05 2012 -0500 @@ -4617,7 +4617,7 @@ )) return NULL; - if (times && (times != Py_None) && ns) { + if (times && (times != Py_None) && ns && (ns != Py_None)) { PyErr_SetString(PyExc_ValueError, "utime: you may specify either 'times'" " or 'ns' but not both"); @@ -4639,7 +4639,7 @@ goto exit; } } - else if (ns) { + else if (ns && (ns != Py_None)) { if (!PyTuple_CheckExact(ns) || (PyTuple_Size(ns) != 2)) { PyErr_SetString(PyExc_TypeError, "utime: 'ns' must be a tuple of two ints");