On Thu, Feb 10, 2022 at 02:27:42PM -0800, Neil Girdhar wrote:
> AttributeError: can't set attribute 'f'
>
> This can be a pain to debug when the property is buried in a base class.
> Would it make sense to mention the reason why the attribute can't be set,
> namely that it's on a property without a setter?
I have no objection to changing the error message, I'm sure it's a small
enough change that you should just open a ticket on b.p.o. for it. But I
don't expect that it will be particularly useful either.
If you can't set an attribute on an object, aren't there three obvious
causes to check?
- the object has no __dict__, and so has no attributes at all;
e.g. trying to set an attribute on a float;
- the object has slots, but 'f' is not one of them;
- or 'f' is a property with no setter (or a setter that raises
AttributeError).
Have I missed any common cases?
Maybe reporting "can't set property 'f'" is good enough.
--
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/Z2AWWETWB72CKARR4DAHB3A2LFRLQR7X/
Code of Conduct: http://python.org/psf/codeofconduct/