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
This commit is contained in:
parent
30864df76d
commit
668973bd44
@ -48,7 +48,7 @@ class TabWindow(QtGui.QMainWindow):
|
|||||||
if hasattr(self.cw, attr):
|
if hasattr(self.cw, attr):
|
||||||
return getattr(self.cw, attr)
|
return getattr(self.cw, attr)
|
||||||
else:
|
else:
|
||||||
raise NameError(attr)
|
raise AttributeError(attr)
|
||||||
|
|
||||||
|
|
||||||
class PlotWindow(PlotWidget):
|
class PlotWindow(PlotWidget):
|
||||||
|
@ -76,7 +76,7 @@ class PlotWidget(GraphicsView):
|
|||||||
m = getattr(self.plotItem, attr)
|
m = getattr(self.plotItem, attr)
|
||||||
if hasattr(m, '__call__'):
|
if hasattr(m, '__call__'):
|
||||||
return m
|
return m
|
||||||
raise NameError(attr)
|
raise AttributeError(attr)
|
||||||
|
|
||||||
def viewRangeChanged(self, view, range):
|
def viewRangeChanged(self, view, range):
|
||||||
#self.emit(QtCore.SIGNAL('viewChanged'), *args)
|
#self.emit(QtCore.SIGNAL('viewChanged'), *args)
|
||||||
|
Loading…
Reference in New Issue
Block a user