Python 3.10 added NameError and AttributeError suggestions in raised exceptions, in the form of:
>>> dim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'dim' is not defined. Did you mean: 'dir'?
This is implemented in Python/suggestions.c and unavailable in the pure Python implementation of traceback formatting in Lib/traceback.py. This makes the output of both different, which is problematic for tooling using traceback.py, as well as for alternative implementations of Python like PyPy and GraalPy.
Let's implement the equivalent of suggestions.c in Lib/traceback.py to bring both in line.
Python 3.10 added NameError and AttributeError suggestions in raised exceptions, in the form of:
This is implemented in
Python/suggestions.cand unavailable in the pure Python implementation of traceback formatting inLib/traceback.py. This makes the output of both different, which is problematic for tooling usingtraceback.py, as well as for alternative implementations of Python like PyPy and GraalPy.Let's implement the equivalent of
suggestions.cinLib/traceback.pyto bring both in line.