Skip to content

Commit 7a91457

Browse files
committed
issue #164 - set Cython language to 3 + other version 3 fixes
1 parent ba52329 commit 7a91457

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*.pyc
66
*.pyd
77
/javabridge/jars/*java2cpython.*
8-
/javabridge/_javabridge.so
8+
/javabridge/*.so
99
/python_javabridge.egg-info
1010
/docs/_build
1111
*.class
@@ -17,3 +17,4 @@
1717
/docs/build
1818
/javabridge.egg-info
1919
/javabridge/_version.py
20+
.coverage

_javabridge.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# cython: language_level=3
12
"""_javabridge.pyx - low-level interface to the JVM
23
34
python-javabridge is licensed under the BSD license. See the
@@ -798,7 +799,7 @@ cdef class JB_Env:
798799
utf8name = name.encode('utf-8')
799800
c = self.env[0].FindClass(self.env, utf8name)
800801
if c == NULL:
801-
print "Failed to get class "+name
802+
print("Failed to get class "+name)
802803
return
803804
cref = self.env[0].NewGlobalRef(self.env, c)
804805
if cref == NULL:
@@ -1640,7 +1641,7 @@ cdef class JB_Env:
16401641
jsize nchars
16411642
jobject o
16421643
u16 = u.encode("utf-16")
1643-
nchars = len(u16) / 2 - 1
1644+
nchars = len(u16) // 2 - 1
16441645
s = u16
16451646
o = self.env[0].NewString(self.env, <jchar *>s+1, nchars)
16461647
if o == NULL:

java/org/cellprofiler/javabridge/test/TestCPython.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class TestCPython {
1818
@Test
1919
public void test_01_01_exec() {
2020
try {
21-
new CPython().exec("print 'Hello, world.'\n");
21+
new CPython().exec("print('Hello, world.')\n");
2222
} catch (CPython.WrappedException e) {
2323
fail();
2424
}
@@ -33,15 +33,15 @@ public void test_02_01_threading() {
3333
String code =
3434
"import javabridge\n" +
3535
"import threading\n" +
36-
"print 'yes I did run'\n" +
36+
"print('yes I did run')\n" +
3737
"def do_something()\n" +
38-
" print 'from inside thread'\n" +
38+
" print('from inside thread')\n" +
3939
" system = javabridge.JClassWrapper('java.lang.System')\n" +
4040
" system.setProperty('foo', 'bar')\n" +
4141
"thread=threading.Thread(target=do_something)\n" +
4242
"thread.start()\n" +
4343
"thread.join()\n" +
44-
"print 'yes I did finish'\n";
44+
"print('yes I did finish')\n";
4545
try {
4646
System.out.print(code);
4747
new CPython().exec(code);

java/org_cellprofiler_javabridge_CPython.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
7171
#ifdef __linux__
7272
char buf[1024];
7373
char *python_location = get_property(vm, "python.location");
74-
const char *command = "python -c \"import sysconfig; from os.path import join; print join(sysconfig.get_config_var('LIBDIR'), sysconfig.get_config_var('multiarchsubdir')[1:], sysconfig.get_config_var('LDLIBRARY'))\"";
74+
const char *command = "python -c \"import sysconfig; from os.path import join; print(join(sysconfig.get_config_var('LIBDIR'), sysconfig.get_config_var('multiarchsubdir')[1:], sysconfig.get_config_var('LDLIBRARY')))\"";
7575

7676
if (!python_location) {
7777
size_t len=1024;

0 commit comments

Comments
 (0)