如果我有下面的类: class Item: return super().__getattribute__(a) print ("Calling the second one (AttributeErroron __getattribute__)!")现在,如果我这样做: i=Item()
i.x 它将命中__getattribute_
似乎Python处理AttributeError异常是不标准的。当类定义__getattr__方法时,它会吞并此异常,而不是传播到堆栈顶部。原来的异常丢失了吗?AttributeError('message which should not be lost')print a.test
# Trying get attribute