This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients BTaskaya, james, pablogsal, serhiy.storchaka, vstinner, xtreak, yselivanov
Date 2019-10-28.11:17:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572261479.55.0.0168651037952.issue38530@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-10-28 11:17:59vstinnersetrecipients: + vstinner, serhiy.storchaka, yselivanov, james, pablogsal, xtreak, BTaskaya
2019-10-28 11:17:59vstinnersetmessageid: <1572261479.55.0.0168651037952.issue38530@roundup.psfhosted.org>
2019-10-28 11:17:59vstinnerlinkissue38530 messages
2019-10-28 11:17:59vstinnercreate