Author: Matti Picus <[email protected]>
Branch: release-pypy3.5-5.x
Changeset: r91455:a31624746a5a
Date: 2017-05-30 16:43 +0300
http://bitbucket.org/pypy/pypy/changeset/a31624746a5a/

Log:    merge py3.5 into release branch

diff --git a/pypy/doc/whatsnew-pypy3-head.rst 
b/pypy/doc/whatsnew-pypy3-5.8.0.rst
copy from pypy/doc/whatsnew-pypy3-head.rst
copy to pypy/doc/whatsnew-pypy3-5.8.0.rst
diff --git a/pypy/doc/whatsnew-pypy3-head.rst b/pypy/doc/whatsnew-pypy3-head.rst
--- a/pypy/doc/whatsnew-pypy3-head.rst
+++ b/pypy/doc/whatsnew-pypy3-head.rst
@@ -1,9 +1,9 @@
 =========================
-What's new in PyPy3 5.7+
+What's new in PyPy3 5.8+
 =========================
 
-.. this is the revision after release-pypy3.3-5.7.x was branched
-.. startrev: afbf09453369
+.. this is the revision after release-pypy3.3-5.8.x was branched
+.. startrev: 0f08064cf67c
 
 .. branch: mtest
 Use "<python> -m test" to run the CPython test suite, as documented by CPython,
diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -258,7 +258,7 @@
             lltype.free(oldbuffer, flavor='raw')
 
     def buffer_w(self, space, flags):
-        return ArrayView(ArrayData(self), self.typecode, self.itemsize, False)
+        return ArrayView(ArrayBuffer(self), self.typecode, self.itemsize, 
False)
 
     def descr_append(self, space, w_x):
         """ append(x)
@@ -848,7 +848,7 @@
     v.typecode = k
 unroll_typecodes = unrolling_iterable(types.keys())
 
-class ArrayData(RawBuffer):
+class ArrayBuffer(RawBuffer):
     _immutable_ = True
     readonly = False
     def __init__(self, w_array):
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
@@ -229,6 +229,14 @@
         'POSIX_FADV_RANDOM', 'POSIX_FADV_NOREUSE', 'POSIX_FADV_DONTNEED']:
             assert getattr(rposix, _name) is not None, "missing %r" % (_name,)
             interpleveldefs[_name] = 'space.wrap(%d)' % getattr(rposix, _name)
+    
+    if hasattr(rposix, 'sched_get_priority_max'):
+        interpleveldefs['sched_get_priority_max'] = 
'interp_posix.sched_get_priority_max'
+        interpleveldefs['sched_get_priority_min'] = 
'interp_posix.sched_get_priority_min'
+        for _name in ['SCHED_FIFO', 'SCHED_RR', 'SCHED_OTHER',
+        'SCHED_BATCH']:
+            assert getattr(rposix, _name) is not None, "missing %r" % (_name,)
+            interpleveldefs[_name] = 'space.wrap(%d)' % getattr(rposix, _name)
 
     for _name in ["O_CLOEXEC"]:
         if getattr(rposix, _name) is not None:
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
@@ -2376,6 +2376,10 @@
 
 @unwrap_spec(fd=c_int)
 def get_blocking(space, fd):
+    """get_blocking(fd) -> bool
+
+Get the blocking mode of the file descriptor:
+False if the O_NONBLOCK flag is set, True if the flag is cleared."""
     try:
         flags = rposix.get_status_flags(fd)
     except OSError as e:
@@ -2384,6 +2388,12 @@
 
 @unwrap_spec(fd=c_int, blocking=int)
 def set_blocking(space, fd, blocking):
+    """\
+set_blocking(fd, blocking)
+
+Set the blocking mode of the specified file descriptor.
+Set the O_NONBLOCK flag if blocking is False,
+clear the O_NONBLOCK flag otherwise."""
     try:
         flags = rposix.get_status_flags(fd)
         if blocking:
@@ -2396,6 +2406,10 @@
 
 @unwrap_spec(out=c_int, count=int)
 def sendfile(space, out, w_in, w_offset, count):
+    """\
+sendfile(out, in, offset, count[, headers][, trailers], flags=0)
+            -> byteswritten
+Copy count bytes from file descriptor in to file descriptor out."""
     # why is an argument called "in"???  that doesn't make sense (it is
     # a reserved word), but that's what CPython does
     in_ = space.c_int_w(w_in)
@@ -2418,3 +2432,31 @@
             except OSError as e:
                 wrap_oserror(space, e, eintr_retry=True)
     return space.newint(res)
+
+@unwrap_spec(policy=int)
+def sched_get_priority_max(space, policy):
+    """returns the maximum priority value that 
+    can be used with the scheduling algorithm 
+    identified by policy
+    """
+    while True:
+        try:
+            s = rposix.sched_get_priority_max(policy)
+        except OSError as e:
+            wrap_oserror(space, e, eintr_retry=True)
+        else:
+           return space.newint(s)
+
+@unwrap_spec(policy=int)
+def sched_get_priority_min(space, policy):
+    """returns the minimum priority value that
+     can be used with the scheduling algorithm 
+     identified by policy
+    """
+    while True:
+        try:
+            s = rposix.sched_get_priority_min(policy)
+        except OSError as e:
+            wrap_oserror(space, e, eintr_retry=True)
+        else:
+           return space.newint(s)
diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -937,6 +937,34 @@
             assert os.WIFEXITED(status1)
             assert os.WEXITSTATUS(status1) == 0   # else, test failure
 
+    if hasattr(rposix, 'sched_get_priority_max'):
+        def test_os_sched_get_priority_max(self):
+            import sys
+            posix, os = self.posix, self.os
+            assert posix.sched_get_priority_max(posix.SCHED_FIFO) != -1
+            assert posix.sched_get_priority_max(posix.SCHED_RR) != -1
+            assert posix.sched_get_priority_max(posix.SCHED_OTHER) != -1
+            assert posix.sched_get_priority_max(posix.SCHED_BATCH) != -1
+
+    if hasattr(rposix, 'sched_get_priority_min'):
+        def test_os_sched_get_priority_min(self):
+            import sys
+            posix, os = self.posix, self.os
+            assert posix.sched_get_priority_min(posix.SCHED_FIFO) != -1
+            assert posix.sched_get_priority_min(posix.SCHED_RR) != -1
+            assert posix.sched_get_priority_min(posix.SCHED_OTHER) != -1
+            assert posix.sched_get_priority_min(posix.SCHED_BATCH) != -1
+            
+    if hasattr(rposix, 'sched_get_priority_min'):
+        def test_os_sched_priority_max_greater_than_min(self):
+            posix, os = self.posix, self.os
+            policy = posix.SCHED_RR
+            low = posix.sched_get_priority_min(policy)
+            high = posix.sched_get_priority_max(policy)
+            assert isinstance(low, int) == True
+            assert isinstance(high, int) == True
+            assert  high > low
+
     def test_write_buffer(self):
         os = self.posix
         fd = os.open(self.path2 + 'test_write_buffer',
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -235,6 +235,7 @@
     includes = ['unistd.h',  'sys/types.h', 'sys/wait.h',
                 'utime.h', 'sys/time.h', 'sys/times.h',
                 'sys/resource.h',
+                'sched.h',
                 'grp.h', 'dirent.h', 'sys/stat.h', 'fcntl.h',
                 'signal.h', 'sys/utsname.h', _ptyh]
     if sys.platform.startswith('linux'):
@@ -255,6 +256,10 @@
     PRIO_PROCESS = rffi_platform.DefinedConstantInteger('PRIO_PROCESS')
     PRIO_PGRP = rffi_platform.DefinedConstantInteger('PRIO_PGRP')
     PRIO_USER = rffi_platform.DefinedConstantInteger('PRIO_USER')
+    SCHED_FIFO = rffi_platform.DefinedConstantInteger('SCHED_FIFO')
+    SCHED_RR = rffi_platform.DefinedConstantInteger('SCHED_RR')
+    SCHED_OTHER = rffi_platform.DefinedConstantInteger('SCHED_OTHER')
+    SCHED_BATCH = rffi_platform.DefinedConstantInteger('SCHED_BATCH')
     O_NONBLOCK = rffi_platform.DefinedConstantInteger('O_NONBLOCK')
     OFF_T = rffi_platform.SimpleType('off_t')
     OFF_T_SIZE = rffi_platform.SizeOf('off_t')
@@ -1818,6 +1823,21 @@
     def setpriority(which, who, prio):
         handle_posix_error('setpriority', c_setpriority(which, who, prio))
 
+    c_sched_get_priority_max = external('sched_get_priority_max', [rffi.INT],
+                              rffi.INT, save_err=rffi.RFFI_FULL_ERRNO_ZERO)
+    c_sched_get_priority_min = external('sched_get_priority_min', [rffi.INT],
+                             rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO)
+
+    @enforceargs(int)
+    def sched_get_priority_max(policy):
+        return handle_posix_error('sched_get_priority_max', 
c_sched_get_priority_max(policy))
+
+    @enforceargs(int)
+    def sched_get_priority_min(policy):
+        return handle_posix_error('sched_get_priority_min', 
c_sched_get_priority_min(policy))
+
+
+
 
 #___________________________________________________________________
 
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -781,3 +781,27 @@
             raise
     finally:
         os.close(fd)
+
+@rposix_requires('sched_get_priority_max')
+def test_sched_get_priority_max():
+    assert rposix.sched_get_priority_max(rposix.SCHED_FIFO) != -1
+    assert rposix.sched_get_priority_max(rposix.SCHED_RR) != -1
+    assert rposix.sched_get_priority_max(rposix.SCHED_OTHER) != -1
+    assert rposix.sched_get_priority_max(rposix.SCHED_BATCH) != -1
+    
+@rposix_requires('sched_get_priority_min')
+def test_sched_get_priority_min():
+    assert rposix.sched_get_priority_min(rposix.SCHED_FIFO) != -1
+    assert rposix.sched_get_priority_min(rposix.SCHED_RR) != -1
+    assert rposix.sched_get_priority_min(rposix.SCHED_OTHER) != -1
+    assert rposix.sched_get_priority_min(rposix.SCHED_BATCH) != -1
+    
+@rposix_requires('sched_get_priority_min')
+def test_os_sched_priority_max_greater_than_min():
+    policy = rposix.SCHED_RR
+    low = rposix.sched_get_priority_min(policy)
+    high = rposix.sched_get_priority_max(policy)
+    assert isinstance(low, int) == True
+    assert isinstance(high, int) == True
+    assert  high > low
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to