[pypy-commit] pypy default: Issue #2270 (part): accept and round down floats in resource.setrlimit()
arigo
pypy.commits at gmail.com
Thu Aug 18 08:55:28 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r86272:aa0294523cbe
Date: 2016-08-18 14:47 +0200
http://bitbucket.org/pypy/pypy/changeset/aa0294523cbe/
Log: Issue #2270 (part): accept and round down floats in
resource.setrlimit()
diff --git a/lib_pypy/resource.py b/lib_pypy/resource.py
--- a/lib_pypy/resource.py
+++ b/lib_pypy/resource.py
@@ -86,7 +86,11 @@
if len(limits) != 2:
raise ValueError("expected a tuple of 2 integers")
- if lib.my_setrlimit(resource, limits[0], limits[1]) == -1:
+ # accept and round down floats, like CPython does
+ limit0 = int(limits[0])
+ limit1 = int(limits[1])
+
+ if lib.my_setrlimit(resource, limit0, limit1) == -1:
if ffi.errno == EINVAL:
raise ValueError("current limit exceeds maximum limit")
elif ffi.errno == EPERM:
diff --git a/pypy/module/test_lib_pypy/test_resource.py b/pypy/module/test_lib_pypy/test_resource.py
--- a/pypy/module/test_lib_pypy/test_resource.py
+++ b/pypy/module/test_lib_pypy/test_resource.py
@@ -45,5 +45,8 @@
def test_setrlimit():
# minimal "does not crash" test
- x = resource.getrlimit(resource.RLIMIT_CPU)
- resource.setrlimit(resource.RLIMIT_CPU, x)
+ x, y = resource.getrlimit(resource.RLIMIT_CPU)
+ resource.setrlimit(resource.RLIMIT_CPU, (x, y))
+ x += 0.2
+ y += 0.3
+ resource.setrlimit(resource.RLIMIT_CPU, (x, y)) # truncated to ints
More information about the pypy-commit
mailing list