Skip to content

Commit

Permalink
standardize PY_MAJOR_VERSION checks against 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ndjensen committed Jul 12, 2017
1 parent b8b52bc commit 3b4a2e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/jep/pyembed.c
Expand Up @@ -261,7 +261,7 @@ void pyembed_startup(JNIEnv *env, jobjectArray sharedModulesArgv)
* See github issue #81.
*/
if (sharedModulesArgv != NULL) {
#if PY_MAJOR_VERSION == 2
#if PY_MAJOR_VERSION < 3
char **argv = NULL;
jsize count = 0;
int i = 0;
Expand Down Expand Up @@ -427,7 +427,7 @@ void pyembed_shared_import(JNIEnv *env, jstring module)
PyEval_ReleaseThread(mainThreadState);
}

#if PY_MAJOR_VERSION == 2
#if PY_MAJOR_VERSION < 3
/*
* In python 2.7 when a module is shared between threads it will be run in
* restricted mode because the __builtins__ attribute of the module does not
Expand Down Expand Up @@ -525,7 +525,7 @@ intptr_t pyembed_thread_init(JNIEnv *env, jobject cl, jobject caller,
}

jepThread->tstate = Py_NewInterpreter();
#if PY_MAJOR_VERSION == 2
#if PY_MAJOR_VERSION < 3
if (hasSharedModules) {
shareBuiltins(jepThread);
} else {
Expand Down Expand Up @@ -601,7 +601,7 @@ void pyembed_thread_close(JNIEnv *env, intptr_t _jepThread)
}

PyEval_AcquireThread(jepThread->tstate);
#if PY_MAJOR_VERSION == 2
#if PY_MAJOR_VERSION < 3
if (jepThread->originalBuiltins) {
unshareBuiltins(jepThread);
}
Expand Down
2 changes: 1 addition & 1 deletion src/jep/pyembed.h
Expand Up @@ -44,7 +44,7 @@ struct __JepThread {
int printStack;
PyObject *fqnToPyJAttrs; /* a dictionary of fully qualified Java
classnames to PyJMethods and PyJFields */
#if PY_MAJOR_VERSION == 2
#if PY_MAJOR_VERSION < 3
PyObject *originalBuiltins;
#endif
};
Expand Down

0 comments on commit 3b4a2e9

Please sign in to comment.