cpython/Modules/errnomodule.c

/* Errno module */

// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h"   // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
#define Py_LIMITED_API
#endif

#include "Python.h"
#include <errno.h>                // EPIPE

/* Windows socket errors (WSA*)  */
#ifdef MS_WINDOWS
#  ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#  endif
#  include <windows.h>

   // The following constants were added to errno.h in VS2010 but have
   // preferred WSA equivalents.
#  undef EADDRINUSE
#  undef EADDRNOTAVAIL
#  undef EAFNOSUPPORT
#  undef EALREADY
#  undef ECONNABORTED
#  undef ECONNREFUSED
#  undef ECONNRESET
#  undef EDESTADDRREQ
#  undef EHOSTUNREACH
#  undef EINPROGRESS
#  undef EISCONN
#  undef ELOOP
#  undef EMSGSIZE
#  undef ENETDOWN
#  undef ENETRESET
#  undef ENETUNREACH
#  undef ENOBUFS
#  undef ENOPROTOOPT
#  undef ENOTCONN
#  undef ENOTSOCK
#  undef EOPNOTSUPP
#  undef EPROTONOSUPPORT
#  undef EPROTOTYPE
#  undef ETIMEDOUT
#  undef EWOULDBLOCK
#endif

/*
 * Pull in the system error definitions
 */

static PyMethodDef errno_methods[] =;

/* Helper function doing the dictionary inserting */

static int
_add_errcode(PyObject *module_dict, PyObject *error_dict, const char *name_str, int code_int)
{}

static int
errno_exec(PyObject *module)
{}

static PyModuleDef_Slot errno_slots[] =;

PyDoc_STRVAR(errno__doc__,
"This module makes available standard errno system symbols.\n\
\n\
The value of each symbol is the corresponding integer value,\n\
e.g., on most systems, errno.ENOENT equals the integer 2.\n\
\n\
The dictionary errno.errorcode maps numeric codes to symbol names,\n\
e.g., errno.errorcode[2] could be the string 'ENOENT'.\n\
\n\
Symbols that are not relevant to the underlying system are not defined.\n\
\n\
To map error codes to error messages, use the function os.strerror(),\n\
e.g. os.strerror(2) could return 'No such file or directory'.");

static struct PyModuleDef errnomodule =;

PyMODINIT_FUNC
PyInit_errno(void)
{}