bpo-38530: Offer suggestions on AttributeError (#16856)
When printing AttributeError, PyErr_Display will offer suggestions of similar
attribute names in the object that the exception was raised from:
>>> collections.namedtoplo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'collections' has no attribute 'namedtoplo'. Did you mean: namedtuple?
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 4dea670..8fdd6eb 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -149,6 +149,13 @@
assignment fails. (When an object does not support attribute references or
attribute assignments at all, :exc:`TypeError` is raised.)
+ The :attr:`name` and :attr:`obj` attributes can be set using keyword-only
+ arguments to the constructor. When set they represent the name of the attribute
+ that was attempted to be accessed and the object that was accessed for said
+ attribute, respectively.
+
+ .. versionchanged:: 3.10
+ Added the :attr:`name` and :attr:`obj` attributes.
.. exception:: EOFError