[pypy-commit] pypy py3.5: Change return type of os.times to posix.times_result

thisch pypy.commits at gmail.com
Wed Nov 15 10:17:32 EST 2017


Author: Thomas Hisch <t.hisch at gmail.com>
Branch: py3.5
Changeset: r93040:852c26ea2a1c
Date: 2017-11-12 21:49 +0100
http://bitbucket.org/pypy/pypy/changeset/852c26ea2a1c/

Log:	Change return type of os.times to posix.times_result

	The return type was changed in CPython3.3.

	Related: #2375

diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -18,6 +18,7 @@
         'error': 'app_posix.error',
         'stat_result': 'app_posix.stat_result',
         'statvfs_result': 'app_posix.statvfs_result',
+        'times_result': 'app_posix.times_result',
         'uname_result': 'app_posix.uname_result',
         'urandom': 'app_posix.urandom',
         'terminal_size': 'app_posix.terminal_size',
diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py
--- a/pypy/module/posix/app_posix.py
+++ b/pypy/module/posix/app_posix.py
@@ -122,6 +122,19 @@
 else:
     _validate_fd = validate_fd
 
+
+class times_result(metaclass=structseqtype):
+
+    name = "posix.times_result"
+    __module__ = "posix"
+
+    user = structseqfield(0, "user time")
+    system = structseqfield(1, "system time")
+    children_user = structseqfield(2, "user time of children")
+    children_system = structseqfield(3, "system time of children")
+    elapsed = structseqfield(4, "elapsed time since an arbitray point in the past")
+
+
 if osname == 'posix':
     def wait():
         """ wait() -> (pid, status)
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
@@ -684,11 +684,17 @@
     except OSError as e:
         raise wrap_oserror(space, e, eintr_retry=False)
     else:
-        return space.newtuple([space.newfloat(times[0]),
-                               space.newfloat(times[1]),
-                               space.newfloat(times[2]),
-                               space.newfloat(times[3]),
-                               space.newfloat(times[4])])
+        w_keywords = space.newdict()
+        w_tuple = space.newtuple([space.newfloat(times[0]),
+                                  space.newfloat(times[1]),
+                                  space.newfloat(times[2]),
+                                  space.newfloat(times[3]),
+                                  space.newfloat(times[4])])
+
+        w_times_result = space.getattr(space.getbuiltinmodule(os.name),
+                                       space.newtext('times_result'))
+        return space.call_function(w_times_result, w_tuple, w_keywords)
+
 
 @unwrap_spec(command='fsencode')
 def system(space, command):


More information about the pypy-commit mailing list