[pypy-svn] r45967 - in pypy/branch/pypy-more-rtti-inprogress/rpython: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Aug 24 19:06:27 CEST 2007
Author: arigo
Date: Fri Aug 24 19:06:27 2007
New Revision: 45967
Modified:
pypy/branch/pypy-more-rtti-inprogress/rpython/rbool.py
pypy/branch/pypy-more-rtti-inprogress/rpython/rfloat.py
pypy/branch/pypy-more-rtti-inprogress/rpython/rint.py
pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_rbuiltin.py
Log:
Test and fixes for missing exception_cannot_occur() in calls to int().
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/rbool.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/rbool.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/rbool.py Fri Aug 24 19:06:27 2007
@@ -29,6 +29,7 @@
def rtype_int(_, hop):
vlist = hop.inputargs(Signed)
+ hop.exception_cannot_occur()
return vlist[0]
def rtype_float(_, hop):
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/rfloat.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/rfloat.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/rfloat.py Fri Aug 24 19:06:27 2007
@@ -138,6 +138,9 @@
def rtype_int(_, hop):
vlist = hop.inputargs(Float)
+ # int(x) never raises in RPython, you need to use
+ # rarithmetic.ovfcheck_float_to_int() if you want this
+ hop.exception_cannot_occur()
return hop.genop('cast_float_to_int', vlist, resulttype=Signed)
rtype_float = rtype_pos
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/rint.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/rint.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/rint.py Fri Aug 24 19:06:27 2007
@@ -369,6 +369,7 @@
if self.lowleveltype in (Unsigned, UnsignedLongLong):
raise TyperError("use intmask() instead of int(r_uint(...))")
vlist = hop.inputargs(Signed)
+ hop.exception_cannot_occur()
return vlist[0]
def rtype_float(_, hop):
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_rbuiltin.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_rbuiltin.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/test/test_rbuiltin.py Fri Aug 24 19:06:27 2007
@@ -364,6 +364,16 @@
res = self.ll_to_string(self.interpret(fn, ['a', 'b']))
assert res == os.path.join('a', 'b')
+ def test_exceptions(self):
+ def fn(a):
+ try:
+ a += int(str(int(a)))
+ a += int(int(a > 5))
+ finally:
+ return a
+ res = self.interpret(fn, [3.25])
+ assert res == 7.25
+
class TestLLtype(BaseTestRbuiltin, LLRtypeMixin):
def test_isinstance_obj(self):
More information about the Pypy-commit
mailing list