File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/main/java/org/scijava/plugins/scripting/jython Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 3434import javax .script .ScriptEngine ;
3535
3636import org .python .core .PyNone ;
37+ import org .python .core .PyObject ;
3738import org .scijava .plugin .Plugin ;
3839import org .scijava .script .AdaptedScriptLanguage ;
3940import org .scijava .script .ScriptLanguage ;
@@ -59,7 +60,14 @@ public ScriptEngine getScriptEngine() {
5960
6061 @ Override
6162 public Object decode (final Object object ) {
62- return object instanceof PyNone ? null : object ;
63+ if (object instanceof PyNone ) return null ;
64+ if (object instanceof PyObject ) {
65+ // Unwrap Python objects when they wrap Java ones.
66+ final PyObject pyObj = (PyObject ) object ;
67+ final Class <?> javaType = pyObj .getType ().getProxyType ();
68+ if (javaType != null ) return pyObj .__tojava__ (javaType );
69+ }
70+ return object ;
6371 }
6472
6573}
You can’t perform that action at this time.
0 commit comments