Name

PyErr_SetFromErrno

Synopsis

PyObject* PyErr_SetFromErrno(PyObject* type)

Raises an exception of class type, a built-in such as PyExc_OSError, or an exception class created with PyErr_NewException. Takes all details from global variable errno, which C library functions and system calls set for many error cases, and the standard C library function strerror. Returns NULL, so your code can just call:

return PyErr_SetFromErrno(PyExc_IOError);

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.