[pypy-commit] pypy py3.3: Let time.clock_* raise correct subclasses of OSError.
mjacob
noreply at buildbot.pypy.org
Mon Aug 17 14:29:50 CEST 2015
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.3
Changeset: r79017:8294dfc3733a
Date: 2015-08-17 14:29 +0200
http://bitbucket.org/pypy/pypy/changeset/8294dfc3733a/
Log: Let time.clock_* raise correct subclasses of OSError.
diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py
--- a/pypy/module/time/interp_time.py
+++ b/pypy/module/time/interp_time.py
@@ -1,6 +1,6 @@
from rpython.rtyper.tool import rffi_platform as platform
from rpython.rtyper.lltypesystem import rffi
-from pypy.interpreter.error import OperationError, oefmt, strerror as _strerror
+from pypy.interpreter.error import OperationError, oefmt, strerror as _strerror, exception_from_saved_errno
from pypy.interpreter.gateway import unwrap_spec
from rpython.rtyper.lltypesystem import lltype
from rpython.rlib.rarithmetic import intmask
@@ -621,8 +621,7 @@
with lltype.scoped_alloc(TIMESPEC) as timespec:
ret = c_clock_gettime(clk_id, timespec)
if ret != 0:
- raise OperationError(space.w_OSError,
- space.wrap(_get_error_msg()))
+ raise exception_from_saved_errno(space, space.w_OSError)
result = (float(rffi.getintfield(timespec, 'c_tv_sec')) +
float(rffi.getintfield(timespec, 'c_tv_nsec')) * 1e-9)
return space.wrap(result)
@@ -635,16 +634,14 @@
rffi.setintfield(timespec, 'c_tv_nsec', int(frac * 1e9))
ret = c_clock_settime(clk_id, timespec)
if ret != 0:
- raise OperationError(space.w_OSError,
- space.wrap(_get_error_msg()))
+ raise exception_from_saved_errno(space, space.w_OSError)
@unwrap_spec(clk_id='c_int')
def clock_getres(space, clk_id):
with lltype.scoped_alloc(TIMESPEC) as timespec:
ret = c_clock_getres(clk_id, timespec)
if ret != 0:
- raise OperationError(space.w_OSError,
- space.wrap(_get_error_msg()))
+ raise exception_from_saved_errno(space, space.w_OSError)
result = (float(rffi.getintfield(timespec, 'c_tv_sec')) +
float(rffi.getintfield(timespec, 'c_tv_nsec')) * 1e-9)
return space.wrap(result)
More information about the pypy-commit
mailing list