[pypy-svn] r46945 - in pypy/dist/pypy/interpreter: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Sep 27 13:16:52 CEST 2007
Author: arigo
Date: Thu Sep 27 13:16:51 2007
New Revision: 46945
Modified:
pypy/dist/pypy/interpreter/baseobjspace.py
pypy/dist/pypy/interpreter/test/test_objspace.py
Log:
Report this ValueError to app-level.
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Thu Sep 27 13:16:51 2007
@@ -870,6 +870,10 @@
except OverflowError:
raise OperationError(self.w_OverflowError,
self.wrap('integer too large'))
+ except ValueError:
+ raise OperationError(self.w_ValueError,
+ self.wrap('cannot convert negative integer '
+ 'to unsigned int'))
class AppExecCache(SpaceCache):
Modified: pypy/dist/pypy/interpreter/test/test_objspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_objspace.py (original)
+++ pypy/dist/pypy/interpreter/test/test_objspace.py Thu Sep 27 13:16:51 2007
@@ -2,7 +2,7 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter.function import Function
from pypy.interpreter.pycode import PyCode
-from pypy.rlib.rarithmetic import r_longlong
+from pypy.rlib.rarithmetic import r_longlong, r_ulonglong
import sys
# this test isn't so much to test that the objspace interface *works*
@@ -180,6 +180,23 @@
w_obj = space.wrap(-12.34)
space.raises_w(space.w_TypeError, space.r_longlong_w, w_obj)
+ def test_r_ulonglong_w(self):
+ space = self.space
+ w_value = space.wrap(12)
+ res = space.r_ulonglong_w(w_value)
+ assert res == 12
+ assert type(res) is r_ulonglong
+ w_value = space.wrap(r_ulonglong(sys.maxint * 42))
+ res = space.r_ulonglong_w(w_value)
+ assert res == sys.maxint * 42
+ assert type(res) is r_ulonglong
+ w_obj = space.wrap("hello world")
+ space.raises_w(space.w_TypeError, space.r_ulonglong_w, w_obj)
+ w_obj = space.wrap(-12.34)
+ space.raises_w(space.w_TypeError, space.r_ulonglong_w, w_obj)
+ w_obj = space.wrap(-12)
+ space.raises_w(space.w_ValueError, space.r_ulonglong_w, w_obj)
+
class TestModuleMinimal:
def test_sys_exists(self):
More information about the Pypy-commit
mailing list