Skip to content

Commit c7ae8b8

Browse files
authored
fixes for Cython 3.1 support (#753)
#752 identified that a problem existed building from Cython 3.1.0, but it was not clear from the posted errors what the problem was. The problem appears to be that under 3.1.0 long is note defined - several error messages were observed like: ``` Error compiling Cython file: ------------------------------------------------------------ ... score += 10 continue if r == 'S' or r == 'I': if isinstance(arg, int) or ( (isinstance(arg, long) and arg < 2147483648)): ^ ------------------------------------------------------------ jnius/jnius_utils.pxi:323:37: undeclared name not builtin: long ``` The solution is to add `from ctypes import c_long as long` where appropriate, following jswhit/pygrib#265 (comment) Also closes #752
1 parent 8d7ec1e commit c7ae8b8

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

jnius/jnius_conversion.pxi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ cdef void populate_args(JNIEnv *j_env, tuple definition_args, jvalue *j_args, ar
3838
cdef JavaClass jc
3939
cdef PythonJavaClass pc
4040
cdef int index
41+
from ctypes import c_long as long
4142

4243
for index, argtype in enumerate(definition_args):
4344
py_arg = args[index]
@@ -467,6 +468,7 @@ cdef jobject convert_python_to_jobject(JNIEnv *j_env, definition, obj) except *:
467468
cdef JavaClassStorage jcs
468469
cdef PythonJavaClass pc
469470
cdef int index
471+
from ctypes import c_long as long
470472

471473
if definition[0] == 'V':
472474
return NULL
@@ -632,6 +634,7 @@ cdef jobject convert_pyarray_to_java(JNIEnv *j_env, definition, pyarray) except
632634
cdef jclass j_class
633635
cdef JavaObject jo
634636
cdef JavaClass jc
637+
from ctypes import c_long as long
635638

636639
cdef ByteArray a_bytes
637640

jnius/jnius_utils.pxi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ cdef int calculate_score(sign_args, args, is_varargs=False) except *:
278278
cdef JavaClass jc
279279
cdef int args_len = len(args)
280280
cdef int sign_args_len = len(sign_args)
281+
from ctypes import c_long as long
281282

282283
if args_len != sign_args_len and not is_varargs:
283284
# if the number of arguments expected is not the same

0 commit comments

Comments
 (0)