Author: Armin Rigo <ar...@tunes.org> Branch: vmprof Changeset: r76711:e492b2d111b0 Date: 2015-04-04 12:22 +0200 http://bitbucket.org/pypy/pypy/changeset/e492b2d111b0/
Log: Test and fix diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py --- a/pypy/module/_vmprof/interp_vmprof.py +++ b/pypy/module/_vmprof/interp_vmprof.py @@ -4,6 +4,7 @@ from rpython.rtyper.annlowlevel import cast_instance_to_gcref, cast_base_ptr_to_instance from rpython.rlib.objectmodel import we_are_translated from rpython.rlib import jit, rposix, rgc +from rpython.rlib.rarithmetic import ovfcheck_float_to_int from rpython.rtyper.tool import rffi_platform as platform from rpython.rlib.rstring import StringBuilder from pypy.interpreter.baseobjspace import W_Root @@ -222,12 +223,12 @@ assert isinstance(mod_vmprof, Module) # try: - period_usec = int(period * 1000000.0 + 0.5) + period_usec = ovfcheck_float_to_int(period * 1000000.0 + 0.5) if period_usec <= 0: raise ValueError except (ValueError, OverflowError): - raise OperationError(self.w_ValueError, - self.wrap("'period' too large or non positive")) + raise OperationError(space.w_ValueError, + space.wrap("'period' too large or non positive")) # mod_vmprof.vmprof.enable(space, fileno, period_usec) diff --git a/pypy/module/_vmprof/test/test__vmprof.py b/pypy/module/_vmprof/test/test__vmprof.py --- a/pypy/module/_vmprof/test/test__vmprof.py +++ b/pypy/module/_vmprof/test/test__vmprof.py @@ -58,3 +58,11 @@ assert "py:foo:" in s assert "py:foo2:" in s assert no_of_codes2 >= no_of_codes + 2 # some extra codes from tests + + def test_enable_ovf(self): + import _vmprof + raises(ValueError, _vmprof.enable, 999, 0) + raises(ValueError, _vmprof.enable, 999, -2.5) + raises(ValueError, _vmprof.enable, 999, 1e300) + raises(ValueError, _vmprof.enable, 999, 1e300 * 1e300) + raises(ValueError, _vmprof.enable, 999, (1e300*1e300) / (1e300*1e300)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit