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 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) {