Skip to content

Commit cbf7eb8

Browse files
committed
Create separate upcall function for 'PyLong_FromDouble'.
1 parent cfb6c1e commit cbf7eb8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ PyObject * PyLong_FromSsize_t(Py_ssize_t n) {
8585
return PyLong_FromLongLong(n);
8686
}
8787

88-
UPCALL_ID(PyLong_FromLongLong);
88+
UPCALL_ID(PyLong_FromDouble);
8989
PyObject * PyLong_FromDouble(double n) {
90-
return UPCALL_CEXT_O(_jls_PyLong_FromLongLong, n, 1);
90+
return UPCALL_CEXT_O(_jls_PyLong_FromDouble, n);
9191
}
9292

9393
UPCALL_ID(ssize_t);
@@ -112,6 +112,7 @@ void * PyLong_AsVoidPtr(PyObject *obj){
112112
return (void *)UPCALL_CEXT_L(_jls_PyLong_AsVoidPtr, native_to_java(obj));
113113
}
114114

115+
UPCALL_ID(PyLong_FromLongLong);
115116
PyObject * PyLong_FromLong(long n) {
116117
return UPCALL_CEXT_O(_jls_PyLong_FromLongLong, n, 1);
117118
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TruffleCextBuiltins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
import com.oracle.graal.python.builtins.objects.cext.NativeWrappers.PythonObjectNativeWrapper;
8888
import com.oracle.graal.python.builtins.objects.cext.PythonNativeClass;
8989
import com.oracle.graal.python.builtins.objects.cext.PythonNativeNull;
90+
import com.oracle.graal.python.builtins.objects.cext.PythonNativeObject;
9091
import com.oracle.graal.python.builtins.objects.cext.PythonNativeVoidPtr;
9192
import com.oracle.graal.python.builtins.objects.cext.UnicodeObjectNodes.UnicodeAsWideCharNode;
9293
import com.oracle.graal.python.builtins.objects.code.PCode;
@@ -1916,9 +1917,9 @@ private static BigInteger convertToBigInteger(long n) {
19161917
}
19171918

19181919
@Specialization
1919-
Object doPointer(TruffleObject n, @SuppressWarnings("unused") int signed,
1920+
Object doPointer(PythonNativeObject n, @SuppressWarnings("unused") int signed,
19201921
@Cached("create()") CExtNodes.ToSulongNode toSulongNode) {
1921-
return toSulongNode.execute(n);
1922+
return toSulongNode.execute(factory().createNativeVoidPtr((TruffleObject) n.object));
19221923
}
19231924
}
19241925

graalpython/lib-graalpython/python_cext.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ def _PyLong_Sign(n):
331331
return 1
332332

333333

334+
@may_raise
335+
def PyLong_FromDouble(d):
336+
return int(d)
337+
338+
334339
@may_raise
335340
def PyLong_FromString(string, base, negative):
336341
result = int(string, base)

0 commit comments

Comments
 (0)