/// <summary> /// Handle a python error (e.g. clear error) /// </summary> /// <remarks> /// This checks if an error actually occured and clears the error /// </remarks> private void HandlePythonError() { // TODO: Save the python error to a log file? if (Py.PyErr_Occurred() != IntPtr.Zero) { Py.PyErr_Clear(); } return; }
/// <summary> /// Dispose of all PyReferences /// </summary> public void Dispose() { // Release the frame created for PySharp if (_frame != PyZero) { // Return the old frame Py.ExchangePyFrame(_oldFrame); _frame = PyZero; } // Remove any of the references we caused foreach (var pyObject in _pyReferences) { pyObject.Release(); } // Clear any python errors we might have caused Py.PyErr_Clear(); }