STINNER Victor <vstin...@python.org> added the comment:

Helping the developer to suggest a fix introduces a minor but non-zero 
overhead, I would prefer to only enable it as an opt-in option. Maybe enable it 
using in the development mode (-X dev/PYTHONDEVMODE=1)?

> https://github.com/dutc/didyoumean (by James Powell)

This project hooks into PyObject_GetAttr() by modifying PyObject_GetAttr() 
machine code, which is definitely not a portable approach.

Maybe one approach would be to add a way to install a hook to customize 
AttributeError exceptions?

Can this issue be implemented using sys.excepthook?

--

This issue is specific to AttributeError, but I vaguely recall that Yury 
Selivanov told me that he wanted to something but for any exception. Detect the 
most common mistakes and propose a solution. I don't think that he ever sent 
anything in public sadly.

I add Yury in the nosy list.

--

Here is another project which also catch NameError, AttributeError, 
ImportError, TypeError, ValueError, SyntaxError, MemoryError, OverflowError, 
OSError, RuntimeError, etc. :
https://github.com/SylvainDe/DidYouMean-Python

It is implemented with sys.excepthook, but it is also compatible with IPython 
"custom exception handler" (call get_ipython().set_custom_exc()).

By the way, does IPython have a feature like this?

In short, https://github.com/SylvainDe/DidYouMean-Python seems to already 
implement this issue in the proper way, no?

--

Similar project for Ruby:
https://github.com/yuki24/did_you_mean

----------
nosy: +yselivanov

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to