Message355527
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 |
|
Date |
User |
Action |
Args |
2019-10-28 11:17:59 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka, yselivanov, james, pablogsal, xtreak, BTaskaya |
2019-10-28 11:17:59 | vstinner | set | messageid: <1572261479.55.0.0168651037952.issue38530@roundup.psfhosted.org> |
2019-10-28 11:17:59 | vstinner | link | issue38530 messages |
2019-10-28 11:17:59 | vstinner | create | |
|