[pypy-commit] pypy py3k: fix l/utimes args

pjenvey pypy.commits at gmail.com
Tue May 24 20:13:53 EDT 2016


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r84671:45c79e88347b
Date: 2016-05-24 17:12 -0700
http://bitbucket.org/pypy/pypy/changeset/45c79e88347b/

Log:	fix l/utimes args

diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1448,6 +1448,15 @@
             # see comment above
             raise wrap_oserror(space, e)
 
+    if now:
+        # satisfy the translator
+        atime = mtime = 0.0
+    else:
+        # convert back to utimes style floats. loses precision of
+        # nanoseconds but utimes only support microseconds anyway
+        atime = atime_s + (atime_ns / 1e9)
+        mtime = mtime_s + (mtime_ns / 1e9)
+
     if (rposix.HAVE_LUTIMES and
         (dir_fd == DEFAULT_DIR_FD and not follow_symlinks)):
         path_b = path.as_bytes
@@ -1458,14 +1467,12 @@
             if now:
                 rposix.lutimes(path_b, None)
             else:
-                rposix.lutimes(path_b, (atime_s, atime_ns))
+                rposix.lutimes(path_b, (atime, mtime))
             return
         except OSError as e:
             # see comment above
             raise wrap_oserror(space, e)
 
-    # XXX: missing utime_dir_fd support
-
     if not follow_symlinks:
         raise argument_unavailable(space, "utime", "follow_symlinks")
 
@@ -1473,7 +1480,7 @@
         if now:
             call_rposix(utime_now, path, None)
         else:
-            call_rposix(rposix.utime, path, (atime_s, mtime_s))
+            call_rposix(rposix.utime, path, (atime, mtime))
     except OSError as e:
         # see comment above
         raise wrap_oserror(space, e)


More information about the pypy-commit mailing list