Skip to content

Commit

Permalink
Initial support for python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
bsteffensmeier committed Apr 13, 2018
1 parent 57b1441 commit f1ae067
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Building and installing require the JDK, Python, and optionally numpy to be inst

Dependencies
------------
* Python 2.7, 3.3, 3.4, 3.5 or 3.6
* Python 2.7, 3.3, 3.4, 3.5, 3.6 or 3.7

This comment has been minimized.

Copy link
@ndjensen

ndjensen Apr 16, 2018

Member

You need to update setup.py's classifiers variable so pypi.org picks up Python 3.7.

* Java >= 1.7
* NumPy >= 1.7 (optional)

Expand Down
2 changes: 1 addition & 1 deletion release_notes/3.8-notes.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Jep 3.8 Release Notes
*********************
This release emphasized...
It is compatible with Python 2.7, 3.3, 3.4, 3.5, and 3.6.
It is compatible with Python 2.7, 3.3, 3.4, 3.5, 3.6, and 3.7.


Maven layout
Expand Down
4 changes: 2 additions & 2 deletions src/main/c/Jep/jep_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int process_py_exception(JNIEnv *env)
{
PyObject *ptype, *pvalue, *ptrace, *pystack = NULL;
PyObject *message = NULL;
char *m = NULL;
const char *m = NULL;
PyJObject *jexc = NULL;
jobject jepException = NULL;
jstring jmsg;
Expand Down Expand Up @@ -243,7 +243,7 @@ int process_py_exception(JNIEnv *env)
count = 0;
for (i = 0; i < stackSize; i++) {
PyObject *stackEntry, *pyLine;
char *charPyFile, *charPyFunc = NULL;
const char *charPyFile, *charPyFunc = NULL;
int pyLineNum;

stackEntry = PyList_GetItem(pystack, i);
Expand Down
12 changes: 8 additions & 4 deletions src/main/c/Jep/pyembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,9 @@ static PyObject* pyembed_jproxy(PyObject *self, PyObject *args)
}

for (i = 0; i < inum; i++) {
char *str;
jstring jstr;
PyObject *item;
const char *str;
jstring jstr;
PyObject *item;

item = PyList_GET_ITEM(interfaces, i);
if (!PyString_Check(item)) {
Expand Down Expand Up @@ -1663,6 +1663,10 @@ static void pyembed_run_pyc(JepThread *jepThread,
// Python 3.3 added an extra long containing the size of the source.
// https://github.com/python/cpython/commit/5136ac0ca21a05691978df8d0650f902c8ca3463
(void) PyMarshal_ReadLongFromFile(fp);
#if PY_MINOR_VERSION >= 7
// PEP 552 added another long
(void) PyMarshal_ReadLongFromFile(fp);
#endif
#endif
v = (PyObject *) (intptr_t) PyMarshal_ReadLastObjectFromFile(fp);
if (v == NULL || !PyCode_Check(v)) {
Expand Down Expand Up @@ -1714,7 +1718,7 @@ static int maybe_pyc_file(FILE *fp, const char* filename, const char* ext,
int ispyc = 0;
if (ftell(fp) == 0) {
if (fread(buf, 1, 2, fp) == 2
&& (buf[1] << 8 | buf[0]) == halfmagic) {
&& ((unsigned int)buf[1] << 8 | buf[0]) == halfmagic) {
ispyc = 1;
}
rewind(fp);
Expand Down
6 changes: 3 additions & 3 deletions src/main/c/Objects/pyjarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static int pyjarray_init(JNIEnv *env,
case JCHAR_ID: {
int i;
long v = 0;
char *val;
const char *val;
jchar *ar = (jchar *) pyarray->pinnedArray;
if (!value || !PyString_Check(value)) {
if (value && PyInt_Check(value)) {
Expand Down Expand Up @@ -718,7 +718,7 @@ static int pyjarray_setitem(PyJArrayObject *self,
if (PyInt_Check(newitem)) {
((jchar *) self->pinnedArray)[pos] = (jchar) PyInt_AS_LONG(newitem);
} else if (PyString_Check(newitem) && PyString_GET_SIZE(newitem) == 1) {
char *val = PyString_AS_STRING(newitem);
const char *val = PyString_AS_STRING(newitem);
((jchar *) self->pinnedArray)[pos] = (jchar) val[0];
} else {
PyErr_SetString(PyExc_TypeError, "Expected char.");
Expand Down Expand Up @@ -1128,7 +1128,7 @@ static int pyjarray_index(PyJArrayObject *self, PyObject *el)
if (PyInt_Check(el)) {
v = (jchar) PyInt_AS_LONG(el);
} else if (PyString_Check(el) && PyString_GET_SIZE(el) == 1) {
char *val = PyString_AS_STRING(el);
const char *val = PyString_AS_STRING(el);
v = (jchar) val[0];
} else {
PyErr_SetString(PyExc_TypeError, "Expected char.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/c/Objects/pyjobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static PyObject* pyjobject_richcompare(PyJObject *self,
#endif

if (!(*env)->IsInstanceOf(env, self->object, JCOMPARABLE_TYPE)) {
char* jname = PyString_AsString(self->javaClassName);
const char* jname = PyString_AsString(self->javaClassName);
PyErr_Format(PyExc_TypeError, "Invalid comparison operation for Java type %s",
jname);
return NULL;
Expand Down

0 comments on commit f1ae067

Please sign in to comment.