Py.newString fails on non-ascii Java strings, use Py.newStringOrUnicode

This commit is contained in:
Jason P. Leasure 2020-09-25 14:06:03 -04:00
parent a1687a17e1
commit 4c7319c45f

View file

@ -100,7 +100,7 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
// Store the default python path in case we need to reset it later.
defaultPythonPath = new ArrayList<>();
for (Object object : systemState.path) {
defaultPythonPath.add(Py.newString(object.toString()));
defaultPythonPath.add(Py.newStringOrUnicode(object.toString()));
}
// Allow interruption of python code to occur when various code paths are
@ -135,18 +135,18 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
// Add in Ghidra script source directories
for (ResourceFile resourceFile : GhidraScriptUtil.getScriptSourceDirectories()) {
systemState.path.append(Py.newString(resourceFile.getFile(false).getAbsolutePath()));
systemState.path.append(Py.newStringOrUnicode(resourceFile.getFile(false).getAbsolutePath()));
}
for (ResourceFile resourceFile : GhidraScriptUtil.getExplodedCompiledSourceBundlePaths()) {
systemState.path.append(Py.newString(resourceFile.getFile(false).getAbsolutePath()));
systemState.path.append(Py.newStringOrUnicode(resourceFile.getFile(false).getAbsolutePath()));
}
// Add in the PyDev remote debugger module
if (!SystemUtilities.isInDevelopmentMode()) {
File pyDevSrcDir = PyDevUtils.getPyDevSrcDir();
if (pyDevSrcDir != null) {
systemState.path.append(Py.newString(pyDevSrcDir.getAbsolutePath()));
systemState.path.append(Py.newStringOrUnicode(pyDevSrcDir.getAbsolutePath()));
}
}
}