pyjnius
pyjnius copied to clipboard
Remove python long to support Cython >= 3.1.x
In https://github.com/kivy/pyjnius/pull/753#issuecomment-2969400311 it was suggested by @da-woods that the fix for #753 was sub-optimal:
ctypes.c_longprobably isn't the right fix.isinstance(x, long)was testing for the Python 2 long type (which no longer exists in Python 3 - Python 3 just has one integer type that covers both large and small integers).
This PR:
- removes
ctypes.c_long - when scoring method signatures, it better tests argument value ranges for compatibility for both short and integer types
- adds some more test cases
- adds a
debugkwarg for method and constructor invocation that displays the scores of the different methods that are being scored incalculate_scores(). This may be useful when use of thesignaturekwarg is necessary.
Example output:
>>> clz = autoclass("org.jnius.SignatureTest$IntOrLong")
>>> obj = clz(0, debug=True) # could be int or long
[(20, '(I)V', 'V', ('I',), (0,)), (20, '(J)V', 'V', ('J',), (0,))]
Selected (J)V for invocation
(ie. constructors (I)V and (J)V both got score of 20, jnius selected (J)V.
All failures are Pypy 3.8, which Cython 3.1 may not support?
All failures are Pypy 3.8, which Cython 3.1 may not support?
I don't remember if it does or not off the top of my head, but I don't think anything in this change should need Cython 3.1. On earlier versions of Cython, long didn't do a lot except on Python 2.
All failures are Pypy 3.8, which Cython 3.1 may not support?
We already looked at this in #752: see https://github.com/kivy/pyjnius/pull/753#issuecomment-2889148812
- This PR is required for https://github.com/kivy/python-for-android/pull/3180.
CC: @misl6
Hi @cmacdonald, I've just pushed some changes that should fix the CI/CD pipeline, can you please rebase on top of master?
rebased!
@T-Dynamos + @cmacdonald , I guess we're only missing Python 3.13 support (and maybe Cython < 3) removal to process a release?
@misl6 Yes, I believe this is ready for release. I've also tested this PR on Android.