Skip to content

Commit c99be61

Browse files
committed
Test for negative values in test_long.py:test_PyLong_AsUnsignedLong.
1 parent 976e712 commit c99be61

File tree

1 file changed

+9
-5
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests/cpyext

1 file changed

+9
-5
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_long.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ def _reference_aslong(args):
5656
def _reference_as_unsigned_long(args):
5757
# We cannot be sure if we are on 32-bit or 64-bit architecture. So, assume the smaller one.
5858
n = args[0]
59-
if n > 0x7fffffff or n < 0:
59+
if n > 0xffffffff or n < 0:
6060
if sys.version_info.minor >= 6:
61-
raise SystemError
61+
exc = SystemError()
62+
exc.__cause__ = OverflowError()
63+
raise exc
6264
else:
6365
return -1
6466
return int(n)
@@ -171,11 +173,13 @@ def compile_module(self, name):
171173
_reference_as_unsigned_long,
172174
lambda: (
173175
(0,),
174-
# TODO disable because CPython 3.4.1 does not correctly catch exceptions from native
175-
# (-1,),
176+
(-1,),
177+
(-2,),
176178
(0x7fffffff,),
179+
(0xffffffff,),
180+
# we could use larger values on 64-bit systems but how should we know?
177181
),
178-
resultspec="l",
182+
resultspec="k",
179183
argspec='O',
180184
arguments=["PyObject* obj"],
181185
cmpfunc=unhandled_error_compare

0 commit comments

Comments
 (0)