Skip to content

Commit

Permalink
issue #164 - set Cython language to 3 + other version 3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeKamentsky committed May 13, 2019
1 parent ba52329 commit 7a91457
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -5,7 +5,7 @@
*.pyc
*.pyd
/javabridge/jars/*java2cpython.*
/javabridge/_javabridge.so
/javabridge/*.so
/python_javabridge.egg-info
/docs/_build
*.class
Expand All @@ -17,3 +17,4 @@
/docs/build
/javabridge.egg-info
/javabridge/_version.py
.coverage
5 changes: 3 additions & 2 deletions _javabridge.pyx
@@ -1,3 +1,4 @@
# cython: language_level=3
"""_javabridge.pyx - low-level interface to the JVM
python-javabridge is licensed under the BSD license. See the
Expand Down Expand Up @@ -798,7 +799,7 @@ cdef class JB_Env:
utf8name = name.encode('utf-8')
c = self.env[0].FindClass(self.env, utf8name)
if c == NULL:
print "Failed to get class "+name
print("Failed to get class "+name)
return
cref = self.env[0].NewGlobalRef(self.env, c)
if cref == NULL:
Expand Down Expand Up @@ -1640,7 +1641,7 @@ cdef class JB_Env:
jsize nchars
jobject o
u16 = u.encode("utf-16")
nchars = len(u16) / 2 - 1
nchars = len(u16) // 2 - 1
s = u16
o = self.env[0].NewString(self.env, <jchar *>s+1, nchars)
if o == NULL:
Expand Down
8 changes: 4 additions & 4 deletions java/org/cellprofiler/javabridge/test/TestCPython.java
Expand Up @@ -18,7 +18,7 @@ public class TestCPython {
@Test
public void test_01_01_exec() {
try {
new CPython().exec("print 'Hello, world.'\n");
new CPython().exec("print('Hello, world.')\n");
} catch (CPython.WrappedException e) {
fail();
}
Expand All @@ -33,15 +33,15 @@ public void test_02_01_threading() {
String code =
"import javabridge\n" +
"import threading\n" +
"print 'yes I did run'\n" +
"print('yes I did run')\n" +
"def do_something()\n" +
" print 'from inside thread'\n" +
" print('from inside thread')\n" +
" system = javabridge.JClassWrapper('java.lang.System')\n" +
" system.setProperty('foo', 'bar')\n" +
"thread=threading.Thread(target=do_something)\n" +
"thread.start()\n" +
"thread.join()\n" +
"print 'yes I did finish'\n";
"print('yes I did finish')\n";
try {
System.out.print(code);
new CPython().exec(code);
Expand Down
2 changes: 1 addition & 1 deletion java/org_cellprofiler_javabridge_CPython.c
Expand Up @@ -71,7 +71,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
#ifdef __linux__
char buf[1024];
char *python_location = get_property(vm, "python.location");
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'))\"";
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')))\"";

if (!python_location) {
size_t len=1024;
Expand Down

0 comments on commit 7a91457

Please sign in to comment.