Ghidra is a software reverse engineering (SRE) framework
GP-1099: Supporting the __file__ attribute in Jython scripts
Ryan Kurtzcd89f0e00f5d
diff --git a/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java b/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.javaindex e102543058..85053243ee 100644--- a/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java+++ b/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java@@ -211,6 +211,9 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {Py.getThreadState().tracefunc = interruptTraceFunction;+ // The Python import system sets the __file__ attribute to the file it's executing+ setVariable("__file__", new PyString(file.getAbsolutePath()));+// If the remote python debugger is alive, initialize it by calling settrace()if (!SystemUtilities.isInDevelopmentMode() && !SystemUtilities.isInHeadlessMode()) {if (PyDevUtils.getPyDevSrcDir() != null) {