[Python-ideas] Provide additional debug info for OSError and WindowsError

eryk sun eryksun at gmail.com
Fri Apr 12 12:29:23 EDT 2019


On 4/12/19, Giampaolo Rodola' <g.rodola at gmail.com> wrote:
>
> As such I was thinking that perhaps it would be nice to provide 2 new
> cPython APIs:
>
> PyErr_SetFromErrnoWithMsg(PyObject *type, const char *msg)
> PyErr_SetFromWindowsErrWithMsg(int ierr, const char *msg)
> PyErr_SetExcFromWindowsErrWithMsg(PyObject *type, int ierr, const char
> *msg)
>
> With this in place also OSError and WindowsError would probably have
> to host a new "extramsg" attribute or something (but not necessarily).

Existing error handling would benefit from this proposal. win32_error
[1], win32_error_object_error, and PyErr_SetFromWindowsErrWithFunction
[2] take a function name that's currently ignored.

[1]: https://github.com/python/cpython/blob/v3.7.3/Modules/posixmodule.c#L1403
[2]: https://github.com/python/cpython/blob/v3.7.3/PC/winreg.c#L26


More information about the Python-ideas mailing list