Skip to content

Commit

Permalink
Add Jython version check
Browse files Browse the repository at this point in the history
  • Loading branch information
mn-mikke committed Oct 27, 2023
1 parent 33a0f3a commit 206c071
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jetty9MainVersion=9.4.53.v20231009
jetty9MinimalVersion=9.4.53.v20231009
servletApiVersion=3.1.0

# Jython (Java intrapretor for Python language)
jythonVersion=2.7.3

# Gson
gsonVersion=2.9.1

Expand Down
10 changes: 9 additions & 1 deletion h2o-extensions/jython-cfunc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ description = "H2O Jython Udfs"

dependencies {
api project(":h2o-core")
api 'org.python:jython:2.7.3'
api "org.python:jython:${jythonVersion}"

if ("${jythonVersion}".toString() != "2.7.3") {
throw new IllegalStateException(
"This module expects Jython 2.7.3, configured version is ${jythonVersion}. " +
"Please locate org.python.core.imp class (modified from Jython 2.7.3), " +
"upgrade it to your version, port our custom changes (Marked as CUSTOM CHANGE)." +
"Once you've done that you can modify this check.")
}

testImplementation project(":h2o-test-support")
testRuntimeOnly project(":${defaultWebserverModule}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,14 @@ private static void ensureFromList(PyObject mod, PyObject fromlist, String name)
*/
private static void ensureFromList(PyObject mod, PyObject fromlist, String name,
boolean recursive) {
// THE ONLY CUSTOM CHANGE MADE IN THIS FILE
// The last Jython version that contains this "if" statement is 2.7.1b3. The newer versions throw an exception
// on line 1495 "Item in from list not a string". The failing type [None] is created in the library, not in H2O
// code.
if (mod.__findattr__("__path__") == null) {
return;
}
// THE END OF THE CUSTOM CHANGE

// This can happen with imports like "from . import foo"
if (name.length() == 0) {
Expand Down

0 comments on commit 206c071

Please sign in to comment.