]> granicus.if.org Git - python/commitdiff
Issue #22117: Fix os.utime(), it now rounds the timestamp towards minus
authorVictor Stinner <victor.stinner@gmail.com>
Sun, 29 Mar 2015 23:02:57 +0000 (01:02 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Sun, 29 Mar 2015 23:02:57 +0000 (01:02 +0200)
infinity (-inf) instead of rounding towards zero.

Replace _PyTime_ROUND_DOWN with _PyTime_ROUND_FLOOR.

Misc/NEWS
Modules/posixmodule.c

index 96621a147862aa3e88ce20808ba69b694cb4845f..e96d66e0ac0ae3b4ab75647497073a9b2c580867 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,9 @@ Core and Builtins
 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.
 
index 9a44d4697566b72441652f00453a823135f6da67..801305f535f22b1c7b52c31f7e17c649ffb98d30 100644 (file)
@@ -6127,9 +6127,9 @@ os_utime_impl(PyModuleDef *module, path_t *path, PyObject *times, PyObject *ns,
         }
         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;