Skip to content

Ghidra is a software reverse engineering (SRE) framework

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

Jason P. Leasure4c7319c45f63
diff --git a/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java b/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java
index 617f5eba0a..0f338e230c 100644
--- a/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java
+++ b/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java
@@ -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()));
}
}
}