> This would create a boundary, same as PEP 479 does for StopIteration,
> across which AttributeError becomes RuntimeError.
Although my problem is about property as I don't use descriptor here, I think descriptor other than property should also be considered, such as classmethod/staticmethod, and normal descriptor. Raising "RuntimeError: descriptor raised AttributeError" is acceptable for me, but maybe some c code need modification, I don't know.
> Do you have any examples that actually do demonstrate the problem to be solved?
So you want more details about AttributeError in property? I thought property is widely used, and AttributeError occurs at all times. Maybe I've used property too heavy.
In the window example, a simplified demonstration:
if self._backgroundImg is None: #need update, while the number of items changes
self._backgroundImg = loadImg('white.bmp')
for widget in self.widgets:
def show(self, img):
However, widget.item may be None, while e.g. there are four widgets but only three items in total. In this case I should fill the area with white. But in this version of show, I just FORGET item can be None. So the traceback infomation: 'Window' object has no attribute 'backgroundImg'. In fact it takes a while before I find the cause is the AttributeError/__getattr__ mechanism.
> But surely breaking that isn't the same as breaking code that's been explicitly stated to work, and used as sample code, for decades.
I don't know this is such a severe problem. I used to think raising AttributeError in __getattribute__ to trigger __getattr__ is rare.
> any solution that can fix descriptors without also "fixing" __getattribute__ is a lot better
In practice I don't concern __getattribute__. But in my opinion it's better to 'fix' this in python4.
> all of your solutions make it too hard to trigger __getattr__ from a descriptor when you really _do_ want to do so
This is a big problem, OK.
> You didn't comment on the alternative I suggested; would it not satisfy your needs, or have some other problem that makes it unacceptable?
I don't quite understand, you mean adding a subclass of object with the only difference of this behavior?