Skip to content

Commit 2c27bf3

Browse files
committed
Return long long from PyTruffleLong_AsPrimitive
1 parent db53e05 commit 2c27bf3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

graalpython/com.oracle.graal.python.cext/src/longobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ PyLong_AsLongAndOverflow(PyObject *vv, int *overflow)
468468
PyErr_BadInternalCall();
469469
return -1;
470470
}
471-
long result = GraalPyTruffleLong_AsPrimitive(vv, MODE_COERCE_SIGNED, sizeof(long));
471+
long result = (long) GraalPyTruffleLong_AsPrimitive(vv, MODE_COERCE_SIGNED, sizeof(long));
472472
if (result == -1L && PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_OverflowError)) {
473473
PyErr_Clear();
474474
*overflow = _PyLong_Sign(vv);
@@ -485,7 +485,7 @@ long
485485
PyLong_AsLong(PyObject *obj)
486486
{
487487
// GraalPy change: different implementation
488-
return GraalPyTruffleLong_AsPrimitive(obj, MODE_COERCE_SIGNED, sizeof(long));
488+
return (long) GraalPyTruffleLong_AsPrimitive(obj, MODE_COERCE_SIGNED, sizeof(long));
489489
}
490490

491491
/* Get a C int from an int object or any object that has an __index__
@@ -511,7 +511,7 @@ _PyLong_AsInt(PyObject *obj)
511511

512512
Py_ssize_t
513513
PyLong_AsSsize_t(PyObject *vv) {
514-
return GraalPyTruffleLong_AsPrimitive(vv, MODE_PINT_SIGNED, sizeof(Py_ssize_t));
514+
return (Py_ssize_t) GraalPyTruffleLong_AsPrimitive(vv, MODE_PINT_SIGNED, sizeof(Py_ssize_t));
515515
}
516516

517517
/* Get a C unsigned long int from an int object.
@@ -535,7 +535,7 @@ size_t
535535
PyLong_AsSize_t(PyObject *vv)
536536
{
537537
// GraalPy change: different implementation
538-
return GraalPyTruffleLong_AsPrimitive(vv, MODE_PINT_UNSIGNED, sizeof(size_t));
538+
return (size_t) GraalPyTruffleLong_AsPrimitive(vv, MODE_PINT_UNSIGNED, sizeof(size_t));
539539
}
540540

541541
#if 0 // GraalPy change

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Object fromString(Object s, int base, @SuppressWarnings("unused") int negative,
227227
}
228228
}
229229

230-
@CApiBuiltin(ret = ArgDescriptor.Long, args = {PyObject, Int, ArgDescriptor.Long}, call = Ignored)
230+
@CApiBuiltin(ret = LONG_LONG, args = {PyObject, Int, SIZE_T}, call = Ignored)
231231
abstract static class PyTruffleLong_AsPrimitive extends CApiTernaryBuiltinNode {
232232

233233
@Specialization

0 commit comments

Comments
 (0)