03.09.21 10:34, Thomas Grainger пише:
> what's the reason for this not to raise AttributeError?

At least backward compatibility. Currently a TypeError is raised in such
cases, and AttributeError is not a subtype of TypeError.

Also, not always any attribute is involved. For example, float() raises
a TypeError if __float__() returns not float. And even if some dunder
name is involved, rules for resolving special methods and common
attributes are different.

> I assume you asked this question in relation to the 3.11 changes to `with x:` 
> raising TypeError vs AttributeError ?

No, it is not related. It was a bug to raise AttributeError, now it is
fixed, but the fix is not backported for compatibility reasons.

> How about `AttributeNotFoundError` or `AttributeRequiredError` ?

It would be confused with completely unrelated AttributeError.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@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/DE45KOKRPMUV7X2IYHKN26YQGNBJJ2OB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to