AttributeError: 'XXX' object has no attribute '_QwtPlot__data'

This error occurs whenever a QwtPlot object is being destroyed unexpectedly.

So, the solution would be to handle this error:

  • Silently, if we identify that this can occur when exiting Python properly
  • By raising an explicit exception or RuntimeWarning if we confirm that it should not happen