From bcf4e28e170c02abab38dc1194b2a33d3adb13d1 Mon Sep 17 00:00:00 2001 From: Mirko Galimberti Date: Sat, 18 Jun 2022 15:45:28 +0200 Subject: [PATCH] Fixes for PyPy (#627) --- .github/workflows/push.yml | 13 +++++++++++++ jnius/jnius_conversion.pxi | 6 +----- tests/test_jvm_options.py | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e8daea2b..cb7f2a72 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -3,6 +3,7 @@ name: Continuous Integration jobs: Tests: name: base + continue-on-error: true strategy: matrix: python: @@ -11,6 +12,9 @@ jobs: - '3.8' - '3.9' - '3.10' + - 'pypy-3.7' + - 'pypy-3.8' + - 'pypy-3.9' java: - '8' # - '9' # commented out just for faster CI @@ -31,6 +35,15 @@ jobs: architecture: 'x86' - os: macOs-latest architecture: 'x86' + - os: windows-latest + architecture: 'x86' + python: 'pypy-3.7' + - os: windows-latest + architecture: 'x86' + python: 'pypy-3.8' + - os: windows-latest + architecture: 'x86' + python: 'pypy-3.9' runs-on: ${{ matrix.os }} steps: diff --git a/jnius/jnius_conversion.pxi b/jnius/jnius_conversion.pxi index db9e12ba..d3d0b248 100644 --- a/jnius/jnius_conversion.pxi +++ b/jnius/jnius_conversion.pxi @@ -1,5 +1,4 @@ from cpython.version cimport PY_MAJOR_VERSION -from cpython cimport PyUnicode_DecodeUTF16 activeLambdaJavaProxies = set() @@ -257,10 +256,7 @@ cdef convert_jstring_to_python(JNIEnv *j_env, jstring j_string): j_strlen = j_env[0].GetStringLength(j_env, j_string); buffsize = j_strlen * sizeof(jchar) - # py_uni = (j_chars)[:buffsize].decode('utf-16') - # Calling directly into c-api for utf-16 decoding due to Cython code gen - # bug for utf-16: https://github.com/cython/cython/issues/1696 - py_uni = PyUnicode_DecodeUTF16(j_chars, buffsize, NULL, NULL) + py_uni = (j_chars)[:buffsize].decode('utf-16') finally: j_env[0].ReleaseStringChars(j_env, j_string, j_chars) diff --git a/tests/test_jvm_options.py b/tests/test_jvm_options.py index ffb3e6ee..7401ab0b 100644 --- a/tests/test_jvm_options.py +++ b/tests/test_jvm_options.py @@ -15,7 +15,7 @@ class TestJVMOptions: ) def test_jvm_options(self): options = ['-Dtest.var{}=value'.format(i) for i in range(40)] - process = subprocess.Popen(['python', '-c', textwrap.dedent( + process = subprocess.Popen([sys.executable, '-c', textwrap.dedent( '''\ import jnius_config import json