From 668973bd4484907cb9fcec39b341d9c622f8b16e Mon Sep 17 00:00:00 2001 From: vladimir-kraus Date: Fri, 4 Aug 2017 11:32:21 +0200 Subject: [PATCH] raising AttributeError in __getattr__ instead of NameError is the correct way of handling non-existent attributes; otherwise for example hasattr(obj, attribute) would raise NameError instead of returning False if the attribute does not exist --- pyqtgraph/graphicsWindows.py | 2 +- pyqtgraph/widgets/PlotWidget.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/graphicsWindows.py b/pyqtgraph/graphicsWindows.py index 1aa3f3f4..331bb659 100644 --- a/pyqtgraph/graphicsWindows.py +++ b/pyqtgraph/graphicsWindows.py @@ -48,7 +48,7 @@ class TabWindow(QtGui.QMainWindow): if hasattr(self.cw, attr): return getattr(self.cw, attr) else: - raise NameError(attr) + raise AttributeError(attr) class PlotWindow(PlotWidget): diff --git a/pyqtgraph/widgets/PlotWidget.py b/pyqtgraph/widgets/PlotWidget.py index 964307ae..6e10b13a 100644 --- a/pyqtgraph/widgets/PlotWidget.py +++ b/pyqtgraph/widgets/PlotWidget.py @@ -76,7 +76,7 @@ class PlotWidget(GraphicsView): m = getattr(self.plotItem, attr) if hasattr(m, '__call__'): return m - raise NameError(attr) + raise AttributeError(attr) def viewRangeChanged(self, view, range): #self.emit(QtCore.SIGNAL('viewChanged'), *args)