[Python-checkins] cpython: Issue #22117: Fix os.utime(), it now rounds the timestamp towards minus

victor.stinner python-checkins at python.org
Mon Mar 30 01:07:39 CEST 2015


https://hg.python.org/cpython/rev/c26b4b85dfc4
changeset:   95259:c26b4b85dfc4
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Mar 30 01:02:57 2015 +0200
summary:
  Issue #22117: Fix os.utime(), it now rounds the timestamp towards minus
infinity (-inf) instead of rounding towards zero.

Replace _PyTime_ROUND_DOWN with _PyTime_ROUND_FLOOR.

files:
  Misc/NEWS             |  3 +++
  Modules/posixmodule.c |  4 ++--
  2 files changed, 5 insertions(+), 2 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,9 @@
 Library
 -------
 
+- Issue #22117: Fix os.utime(), it now rounds the timestamp towards minus
+  infinity (-inf) instead of rounding towards zero.
+
 - Issue #14260: The groupindex attribute of regular expression pattern object
   now is non-modifiable mapping.
 
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6127,9 +6127,9 @@
         }
         utime.now = 0;
         if (_PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 0),
-                                     &a_sec, &a_nsec, _PyTime_ROUND_DOWN) == -1 ||
+                                     &a_sec, &a_nsec, _PyTime_ROUND_FLOOR) == -1 ||
             _PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 1),
-                                     &m_sec, &m_nsec, _PyTime_ROUND_DOWN) == -1) {
+                                     &m_sec, &m_nsec, _PyTime_ROUND_FLOOR) == -1) {
             goto exit;
         }
         utime.atime_s = a_sec;

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list