diff --git a/MantidPlot/src/PythonScript.cpp b/MantidPlot/src/PythonScript.cpp index c63623e869c6698bc0ce455462d929b029736a5a..6f26d83b33c4c42bab28320f0e8a8aaf95861700 100644 --- a/MantidPlot/src/PythonScript.cpp +++ b/MantidPlot/src/PythonScript.cpp @@ -389,11 +389,17 @@ void PythonScript::clearLocals() { PyObject *value = PyDict_GetItemString(localDict, "__file__"); if (value) PyDict_SetItemString(cleanLocals, "__file__", value); + // reset locals Py_DECREF(localDict); localDict = nullptr; } localDict = cleanLocals; + auto mod = PyImport_ImportModule("mantid.simpleapi"); + PyObject_DelAttrString(mod, "plotSpectrum"); + PyObject_DelAttrString(mod, "plotBin"); + PyErr_Clear(); + Py_DECREF(mod); } /**