errnomodule.c 25.8 KB
Newer Older
1 2 3 4 5

/* Errno module */

#include "Python.h"

6
/* Windows socket errors (WSA*)  */
7
#ifdef MS_WINDOWS
8
#define WIN32_LEAN_AND_MEAN
9
#include <windows.h>
10 11
#endif

12 13
/*
 * Pull in the system error definitions
14
 */
15 16

static PyMethodDef errno_methods[] = {
17
    {NULL,              NULL}
18 19
};

20
/* Helper function doing the dictionary inserting */
21 22

static void
23
_inscode(PyObject *d, PyObject *de, const char *name, int code)
24
{
25 26
    PyObject *u = PyUnicode_FromString(name);
    PyObject *v = PyLong_FromLong((long) code);
27

28 29 30 31 32 33 34 35 36 37 38 39
    /* Don't bother checking for errors; they'll be caught at the end
     * of the module initialization function by the caller of
     * initerrno().
     */
    if (u && v) {
        /* insert in modules dict */
        PyDict_SetItem(d, u, v);
        /* insert in errorcode dict */
        PyDict_SetItem(de, v, u);
    }
    Py_XDECREF(u);
    Py_XDECREF(v);
40 41
}

42
PyDoc_STRVAR(errno__doc__,
43 44 45 46 47 48 49 50 51 52 53
"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\
54
e.g. os.strerror(2) could return 'No such file or directory'.");
55

56
static struct PyModuleDef errnomodule = {
57 58 59 60 61 62 63 64 65
    PyModuleDef_HEAD_INIT,
    "errno",
    errno__doc__,
    -1,
    errno_methods,
    NULL,
    NULL,
    NULL,
    NULL
66 67
};

68
PyMODINIT_FUNC
69
PyInit_errno(void)
70
{
71 72 73 74 75 76 77 78
    PyObject *m, *d, *de;
    m = PyModule_Create(&errnomodule);
    if (m == NULL)
        return NULL;
    d = PyModule_GetDict(m);
    de = PyDict_New();
    if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0)
        return NULL;
79

80 81 82
/* Macro so I don't have to edit each and every line below... */
#define inscode(d, ds, de, name, code, comment) _inscode(d, de, name, code)

83 84
    /*
     * The names and comments are borrowed from linux/include/errno.h,
85 86
     * which should be pretty all-inclusive.  However, the Solaris specific
     * names and comments are borrowed from sys/errno.h in Solaris.
87
     */
88

89
#ifdef ENODEV
90
    inscode(d, ds, de, "ENODEV", ENODEV, "No such device");
91
#endif
92
#ifdef ENOCSI
93
    inscode(d, ds, de, "ENOCSI", ENOCSI, "No CSI structure available");
94
#endif
95
#ifdef EHOSTUNREACH
96
    inscode(d, ds, de, "EHOSTUNREACH", EHOSTUNREACH, "No route to host");
97 98
#else
#ifdef WSAEHOSTUNREACH
99
    inscode(d, ds, de, "EHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
100 101 102
#endif
#endif
#ifdef ENOMSG
103
    inscode(d, ds, de, "ENOMSG", ENOMSG, "No message of desired type");
104 105
#endif
#ifdef EUCLEAN
106
    inscode(d, ds, de, "EUCLEAN", EUCLEAN, "Structure needs cleaning");
107 108
#endif
#ifdef EL2NSYNC
109
    inscode(d, ds, de, "EL2NSYNC", EL2NSYNC, "Level 2 not synchronized");
110 111
#endif
#ifdef EL2HLT
112
    inscode(d, ds, de, "EL2HLT", EL2HLT, "Level 2 halted");
113 114
#endif
#ifdef ENODATA
115
    inscode(d, ds, de, "ENODATA", ENODATA, "No data available");
116 117
#endif
#ifdef ENOTBLK
118
    inscode(d, ds, de, "ENOTBLK", ENOTBLK, "Block device required");
119 120
#endif
#ifdef ENOSYS
121
    inscode(d, ds, de, "ENOSYS", ENOSYS, "Function not implemented");
122 123
#endif
#ifdef EPIPE
124
    inscode(d, ds, de, "EPIPE", EPIPE, "Broken pipe");
125 126
#endif
#ifdef EINVAL
127
    inscode(d, ds, de, "EINVAL", EINVAL, "Invalid argument");
128 129
#else
#ifdef WSAEINVAL
130
    inscode(d, ds, de, "EINVAL", WSAEINVAL, "Invalid argument");
131 132 133
#endif
#endif
#ifdef EOVERFLOW
134
    inscode(d, ds, de, "EOVERFLOW", EOVERFLOW, "Value too large for defined data type");
135 136
#endif
#ifdef EADV
137
    inscode(d, ds, de, "EADV", EADV, "Advertise error");
138 139
#endif
#ifdef EINTR
140
    inscode(d, ds, de, "EINTR", EINTR, "Interrupted system call");
141 142
#else
#ifdef WSAEINTR
143
    inscode(d, ds, de, "EINTR", WSAEINTR, "Interrupted system call");
144 145
#endif
#endif
146
#ifdef EUSERS
147
    inscode(d, ds, de, "EUSERS", EUSERS, "Too many users");
148 149
#else
#ifdef WSAEUSERS
150
    inscode(d, ds, de, "EUSERS", WSAEUSERS, "Too many users");
151 152
#endif
#endif
153
#ifdef ENOTEMPTY
154
    inscode(d, ds, de, "ENOTEMPTY", ENOTEMPTY, "Directory not empty");
155 156
#else
#ifdef WSAENOTEMPTY
157
    inscode(d, ds, de, "ENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
158 159 160
#endif
#endif
#ifdef ENOBUFS
161
    inscode(d, ds, de, "ENOBUFS", ENOBUFS, "No buffer space available");
162 163
#else
#ifdef WSAENOBUFS
164
    inscode(d, ds, de, "ENOBUFS", WSAENOBUFS, "No buffer space available");
165
#endif
166 167
#endif
#ifdef EPROTO
168
    inscode(d, ds, de, "EPROTO", EPROTO, "Protocol error");
169 170
#endif
#ifdef EREMOTE
171
    inscode(d, ds, de, "EREMOTE", EREMOTE, "Object is remote");
172 173
#else
#ifdef WSAEREMOTE
174
    inscode(d, ds, de, "EREMOTE", WSAEREMOTE, "Object is remote");
175 176 177
#endif
#endif
#ifdef ENAVAIL
178
    inscode(d, ds, de, "ENAVAIL", ENAVAIL, "No XENIX semaphores available");
179 180
#endif
#ifdef ECHILD
181
    inscode(d, ds, de, "ECHILD", ECHILD, "No child processes");
182
#endif
183
#ifdef ELOOP
184
    inscode(d, ds, de, "ELOOP", ELOOP, "Too many symbolic links encountered");
185 186
#else
#ifdef WSAELOOP
187
    inscode(d, ds, de, "ELOOP", WSAELOOP, "Too many symbolic links encountered");
188 189
#endif
#endif
190
#ifdef EXDEV
191
    inscode(d, ds, de, "EXDEV", EXDEV, "Cross-device link");
192
#endif
193
#ifdef E2BIG
194
    inscode(d, ds, de, "E2BIG", E2BIG, "Arg list too long");
195 196
#endif
#ifdef ESRCH
197
    inscode(d, ds, de, "ESRCH", ESRCH, "No such process");
198 199
#endif
#ifdef EMSGSIZE
200
    inscode(d, ds, de, "EMSGSIZE", EMSGSIZE, "Message too long");
201 202
#else
#ifdef WSAEMSGSIZE
203
    inscode(d, ds, de, "EMSGSIZE", WSAEMSGSIZE, "Message too long");
204 205 206
#endif
#endif
#ifdef EAFNOSUPPORT
207
    inscode(d, ds, de, "EAFNOSUPPORT", EAFNOSUPPORT, "Address family not supported by protocol");
208 209
#else
#ifdef WSAEAFNOSUPPORT
210
    inscode(d, ds, de, "EAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
211 212 213
#endif
#endif
#ifdef EBADR
214
    inscode(d, ds, de, "EBADR", EBADR, "Invalid request descriptor");
215 216
#endif
#ifdef EHOSTDOWN
217
    inscode(d, ds, de, "EHOSTDOWN", EHOSTDOWN, "Host is down");
218 219
#else
#ifdef WSAEHOSTDOWN
220
    inscode(d, ds, de, "EHOSTDOWN", WSAEHOSTDOWN, "Host is down");
221 222 223
#endif
#endif
#ifdef EPFNOSUPPORT
224
    inscode(d, ds, de, "EPFNOSUPPORT", EPFNOSUPPORT, "Protocol family not supported");
225 226
#else
#ifdef WSAEPFNOSUPPORT
227
    inscode(d, ds, de, "EPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
228 229 230
#endif
#endif
#ifdef ENOPROTOOPT
231
    inscode(d, ds, de, "ENOPROTOOPT", ENOPROTOOPT, "Protocol not available");
232 233
#else
#ifdef WSAENOPROTOOPT
234
    inscode(d, ds, de, "ENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
235 236 237
#endif
#endif
#ifdef EBUSY
238
    inscode(d, ds, de, "EBUSY", EBUSY, "Device or resource busy");
239
#endif
240
#ifdef EWOULDBLOCK
241
    inscode(d, ds, de, "EWOULDBLOCK", EWOULDBLOCK, "Operation would block");
242 243
#else
#ifdef WSAEWOULDBLOCK
244
    inscode(d, ds, de, "EWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
245 246
#endif
#endif
247
#ifdef EBADFD
248
    inscode(d, ds, de, "EBADFD", EBADFD, "File descriptor in bad state");
249 250
#endif
#ifdef EDOTDOT
251
    inscode(d, ds, de, "EDOTDOT", EDOTDOT, "RFS specific error");
252 253
#endif
#ifdef EISCONN
254
    inscode(d, ds, de, "EISCONN", EISCONN, "Transport endpoint is already connected");
255 256
#else
#ifdef WSAEISCONN
257
    inscode(d, ds, de, "EISCONN", WSAEISCONN, "Transport endpoint is already connected");
258 259 260
#endif
#endif
#ifdef ENOANO
261
    inscode(d, ds, de, "ENOANO", ENOANO, "No anode");
262 263
#endif
#ifdef ESHUTDOWN
264
    inscode(d, ds, de, "ESHUTDOWN", ESHUTDOWN, "Cannot send after transport endpoint shutdown");
265 266
#else
#ifdef WSAESHUTDOWN
267
    inscode(d, ds, de, "ESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
268 269 270
#endif
#endif
#ifdef ECHRNG
271
    inscode(d, ds, de, "ECHRNG", ECHRNG, "Channel number out of range");
272 273
#endif
#ifdef ELIBBAD
274
    inscode(d, ds, de, "ELIBBAD", ELIBBAD, "Accessing a corrupted shared library");
275 276
#endif
#ifdef ENONET
277
    inscode(d, ds, de, "ENONET", ENONET, "Machine is not on the network");
278 279
#endif
#ifdef EBADE
280
    inscode(d, ds, de, "EBADE", EBADE, "Invalid exchange");
281 282
#endif
#ifdef EBADF
283
    inscode(d, ds, de, "EBADF", EBADF, "Bad file number");
284 285
#else
#ifdef WSAEBADF
286
    inscode(d, ds, de, "EBADF", WSAEBADF, "Bad file number");
287 288 289
#endif
#endif
#ifdef EMULTIHOP
290
    inscode(d, ds, de, "EMULTIHOP", EMULTIHOP, "Multihop attempted");
291 292
#endif
#ifdef EIO
293
    inscode(d, ds, de, "EIO", EIO, "I/O error");
294 295
#endif
#ifdef EUNATCH
296
    inscode(d, ds, de, "EUNATCH", EUNATCH, "Protocol driver not attached");
297 298
#endif
#ifdef EPROTOTYPE
299
    inscode(d, ds, de, "EPROTOTYPE", EPROTOTYPE, "Protocol wrong type for socket");
300 301
#else
#ifdef WSAEPROTOTYPE
302
    inscode(d, ds, de, "EPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
303 304 305
#endif
#endif
#ifdef ENOSPC
306
    inscode(d, ds, de, "ENOSPC", ENOSPC, "No space left on device");
307 308
#endif
#ifdef ENOEXEC
309
    inscode(d, ds, de, "ENOEXEC", ENOEXEC, "Exec format error");
310 311
#endif
#ifdef EALREADY
312
    inscode(d, ds, de, "EALREADY", EALREADY, "Operation already in progress");
313 314
#else
#ifdef WSAEALREADY
315
    inscode(d, ds, de, "EALREADY", WSAEALREADY, "Operation already in progress");
316 317 318
#endif
#endif
#ifdef ENETDOWN
319
    inscode(d, ds, de, "ENETDOWN", ENETDOWN, "Network is down");
320 321
#else
#ifdef WSAENETDOWN
322
    inscode(d, ds, de, "ENETDOWN", WSAENETDOWN, "Network is down");
323 324 325
#endif
#endif
#ifdef ENOTNAM
326
    inscode(d, ds, de, "ENOTNAM", ENOTNAM, "Not a XENIX named type file");
327 328
#endif
#ifdef EACCES
329
    inscode(d, ds, de, "EACCES", EACCES, "Permission denied");
330 331
#else
#ifdef WSAEACCES
332
    inscode(d, ds, de, "EACCES", WSAEACCES, "Permission denied");
333 334 335
#endif
#endif
#ifdef ELNRNG
336
    inscode(d, ds, de, "ELNRNG", ELNRNG, "Link number out of range");
337 338
#endif
#ifdef EILSEQ
339
    inscode(d, ds, de, "EILSEQ", EILSEQ, "Illegal byte sequence");
340 341
#endif
#ifdef ENOTDIR
342
    inscode(d, ds, de, "ENOTDIR", ENOTDIR, "Not a directory");
343 344
#endif
#ifdef ENOTUNIQ
345
    inscode(d, ds, de, "ENOTUNIQ", ENOTUNIQ, "Name not unique on network");
346 347
#endif
#ifdef EPERM
348
    inscode(d, ds, de, "EPERM", EPERM, "Operation not permitted");
349 350
#endif
#ifdef EDOM
351
    inscode(d, ds, de, "EDOM", EDOM, "Math argument out of domain of func");
352 353
#endif
#ifdef EXFULL
354
    inscode(d, ds, de, "EXFULL", EXFULL, "Exchange full");
355 356
#endif
#ifdef ECONNREFUSED
357
    inscode(d, ds, de, "ECONNREFUSED", ECONNREFUSED, "Connection refused");
358 359
#else
#ifdef WSAECONNREFUSED
360
    inscode(d, ds, de, "ECONNREFUSED", WSAECONNREFUSED, "Connection refused");
361
#endif
362 363
#endif
#ifdef EISDIR
364
    inscode(d, ds, de, "EISDIR", EISDIR, "Is a directory");
365
#endif
366
#ifdef EPROTONOSUPPORT
367
    inscode(d, ds, de, "EPROTONOSUPPORT", EPROTONOSUPPORT, "Protocol not supported");
368 369
#else
#ifdef WSAEPROTONOSUPPORT
370
    inscode(d, ds, de, "EPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
371 372
#endif
#endif
373
#ifdef EROFS
374
    inscode(d, ds, de, "EROFS", EROFS, "Read-only file system");
375
#endif
376
#ifdef EADDRNOTAVAIL
377
    inscode(d, ds, de, "EADDRNOTAVAIL", EADDRNOTAVAIL, "Cannot assign requested address");
378 379
#else
#ifdef WSAEADDRNOTAVAIL
380
    inscode(d, ds, de, "EADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
381 382
#endif
#endif
383
#ifdef EIDRM
384
    inscode(d, ds, de, "EIDRM", EIDRM, "Identifier removed");
385
#endif
386
#ifdef ECOMM
387
    inscode(d, ds, de, "ECOMM", ECOMM, "Communication error on send");
388 389
#endif
#ifdef ESRMNT
390
    inscode(d, ds, de, "ESRMNT", ESRMNT, "Srmount error");
391 392
#endif
#ifdef EREMOTEIO
393
    inscode(d, ds, de, "EREMOTEIO", EREMOTEIO, "Remote I/O error");
394 395
#endif
#ifdef EL3RST
396
    inscode(d, ds, de, "EL3RST", EL3RST, "Level 3 reset");
397 398
#endif
#ifdef EBADMSG
399
    inscode(d, ds, de, "EBADMSG", EBADMSG, "Not a data message");
400 401
#endif
#ifdef ENFILE
402
    inscode(d, ds, de, "ENFILE", ENFILE, "File table overflow");
403 404
#endif
#ifdef ELIBMAX
405
    inscode(d, ds, de, "ELIBMAX", ELIBMAX, "Attempting to link in too many shared libraries");
406 407
#endif
#ifdef ESPIPE
408
    inscode(d, ds, de, "ESPIPE", ESPIPE, "Illegal seek");
409
#endif
410
#ifdef ENOLINK
411
    inscode(d, ds, de, "ENOLINK", ENOLINK, "Link has been severed");
412
#endif
413
#ifdef ENETRESET
414
    inscode(d, ds, de, "ENETRESET", ENETRESET, "Network dropped connection because of reset");
415 416
#else
#ifdef WSAENETRESET
417
    inscode(d, ds, de, "ENETRESET", WSAENETRESET, "Network dropped connection because of reset");
418 419
#endif
#endif
420
#ifdef ETIMEDOUT
421
    inscode(d, ds, de, "ETIMEDOUT", ETIMEDOUT, "Connection timed out");
422 423
#else
#ifdef WSAETIMEDOUT
424
    inscode(d, ds, de, "ETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
425
#endif
426 427
#endif
#ifdef ENOENT
428
    inscode(d, ds, de, "ENOENT", ENOENT, "No such file or directory");
429 430
#endif
#ifdef EEXIST
431
    inscode(d, ds, de, "EEXIST", EEXIST, "File exists");
432 433
#endif
#ifdef EDQUOT
434
    inscode(d, ds, de, "EDQUOT", EDQUOT, "Quota exceeded");
435 436
#else
#ifdef WSAEDQUOT
437
    inscode(d, ds, de, "EDQUOT", WSAEDQUOT, "Quota exceeded");
438 439 440
#endif
#endif
#ifdef ENOSTR
441
    inscode(d, ds, de, "ENOSTR", ENOSTR, "Device not a stream");
442 443
#endif
#ifdef EBADSLT
444
    inscode(d, ds, de, "EBADSLT", EBADSLT, "Invalid slot");
445 446
#endif
#ifdef EBADRQC
447
    inscode(d, ds, de, "EBADRQC", EBADRQC, "Invalid request code");
448 449
#endif
#ifdef ELIBACC
450
    inscode(d, ds, de, "ELIBACC", ELIBACC, "Can not access a needed shared library");
451 452
#endif
#ifdef EFAULT
453
    inscode(d, ds, de, "EFAULT", EFAULT, "Bad address");
454 455
#else
#ifdef WSAEFAULT
456
    inscode(d, ds, de, "EFAULT", WSAEFAULT, "Bad address");
457 458 459
#endif
#endif
#ifdef EFBIG
460
    inscode(d, ds, de, "EFBIG", EFBIG, "File too large");
461 462
#endif
#ifdef EDEADLK
463
    inscode(d, ds, de, "EDEADLK", EDEADLK, "Resource deadlock would occur");
464 465
#endif
#ifdef ENOTCONN
466
    inscode(d, ds, de, "ENOTCONN", ENOTCONN, "Transport endpoint is not connected");
467 468
#else
#ifdef WSAENOTCONN
469
    inscode(d, ds, de, "ENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
470 471 472
#endif
#endif
#ifdef EDESTADDRREQ
473
    inscode(d, ds, de, "EDESTADDRREQ", EDESTADDRREQ, "Destination address required");
474 475
#else
#ifdef WSAEDESTADDRREQ
476
    inscode(d, ds, de, "EDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
477
#endif
478 479
#endif
#ifdef ELIBSCN
480
    inscode(d, ds, de, "ELIBSCN", ELIBSCN, ".lib section in a.out corrupted");
481 482
#endif
#ifdef ENOLCK
483
    inscode(d, ds, de, "ENOLCK", ENOLCK, "No record locks available");
484
#endif
485
#ifdef EISNAM
486
    inscode(d, ds, de, "EISNAM", EISNAM, "Is a named type file");
487
#endif
488
#ifdef ECONNABORTED
489
    inscode(d, ds, de, "ECONNABORTED", ECONNABORTED, "Software caused connection abort");
490 491
#else
#ifdef WSAECONNABORTED
492
    inscode(d, ds, de, "ECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
493 494
#endif
#endif
495
#ifdef ENETUNREACH
496
    inscode(d, ds, de, "ENETUNREACH", ENETUNREACH, "Network is unreachable");
497 498
#else
#ifdef WSAENETUNREACH
499
    inscode(d, ds, de, "ENETUNREACH", WSAENETUNREACH, "Network is unreachable");
500 501
#endif
#endif
502
#ifdef ESTALE
503
    inscode(d, ds, de, "ESTALE", ESTALE, "Stale NFS file handle");
504 505
#else
#ifdef WSAESTALE
506
    inscode(d, ds, de, "ESTALE", WSAESTALE, "Stale NFS file handle");
507 508
#endif
#endif
509
#ifdef ENOSR
510
    inscode(d, ds, de, "ENOSR", ENOSR, "Out of streams resources");
511 512
#endif
#ifdef ENOMEM
513
    inscode(d, ds, de, "ENOMEM", ENOMEM, "Out of memory");
514 515
#endif
#ifdef ENOTSOCK
516
    inscode(d, ds, de, "ENOTSOCK", ENOTSOCK, "Socket operation on non-socket");
517 518
#else
#ifdef WSAENOTSOCK
519
    inscode(d, ds, de, "ENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
520 521 522
#endif
#endif
#ifdef ESTRPIPE
523
    inscode(d, ds, de, "ESTRPIPE", ESTRPIPE, "Streams pipe error");
524 525
#endif
#ifdef EMLINK
526
    inscode(d, ds, de, "EMLINK", EMLINK, "Too many links");
527 528
#endif
#ifdef ERANGE
529
    inscode(d, ds, de, "ERANGE", ERANGE, "Math result not representable");
530 531
#endif
#ifdef ELIBEXEC
532
    inscode(d, ds, de, "ELIBEXEC", ELIBEXEC, "Cannot exec a shared library directly");
533 534
#endif
#ifdef EL3HLT
535
    inscode(d, ds, de, "EL3HLT", EL3HLT, "Level 3 halted");
536
#endif
537
#ifdef ECONNRESET
538
    inscode(d, ds, de, "ECONNRESET", ECONNRESET, "Connection reset by peer");
539 540
#else
#ifdef WSAECONNRESET
541
    inscode(d, ds, de, "ECONNRESET", WSAECONNRESET, "Connection reset by peer");
542 543
#endif
#endif
544
#ifdef EADDRINUSE
545
    inscode(d, ds, de, "EADDRINUSE", EADDRINUSE, "Address already in use");
546 547
#else
#ifdef WSAEADDRINUSE
548
    inscode(d, ds, de, "EADDRINUSE", WSAEADDRINUSE, "Address already in use");
549 550
#endif
#endif
551
#ifdef EOPNOTSUPP
552
    inscode(d, ds, de, "EOPNOTSUPP", EOPNOTSUPP, "Operation not supported on transport endpoint");
553 554
#else
#ifdef WSAEOPNOTSUPP
555
    inscode(d, ds, de, "EOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
556 557
#endif
#endif
558
#ifdef EREMCHG
559
    inscode(d, ds, de, "EREMCHG", EREMCHG, "Remote address changed");
560
#endif
561
#ifdef EAGAIN
562
    inscode(d, ds, de, "EAGAIN", EAGAIN, "Try again");
563
#endif
564
#ifdef ENAMETOOLONG
565
    inscode(d, ds, de, "ENAMETOOLONG", ENAMETOOLONG, "File name too long");
566 567
#else
#ifdef WSAENAMETOOLONG
568
    inscode(d, ds, de, "ENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
569 570
#endif
#endif
571
#ifdef ENOTTY
572
    inscode(d, ds, de, "ENOTTY", ENOTTY, "Not a typewriter");
573 574
#endif
#ifdef ERESTART
575
    inscode(d, ds, de, "ERESTART", ERESTART, "Interrupted system call should be restarted");
576 577
#endif
#ifdef ESOCKTNOSUPPORT
578
    inscode(d, ds, de, "ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, "Socket type not supported");
579 580
#else
#ifdef WSAESOCKTNOSUPPORT
581
    inscode(d, ds, de, "ESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
582
#endif
583 584
#endif
#ifdef ETIME
585
    inscode(d, ds, de, "ETIME", ETIME, "Timer expired");
586 587
#endif
#ifdef EBFONT
588
    inscode(d, ds, de, "EBFONT", EBFONT, "Bad font file format");
589
#endif
590
#ifdef EDEADLOCK
591
    inscode(d, ds, de, "EDEADLOCK", EDEADLOCK, "Error EDEADLOCK");
592
#endif
593
#ifdef ETOOMANYREFS
594
    inscode(d, ds, de, "ETOOMANYREFS", ETOOMANYREFS, "Too many references: cannot splice");
595 596
#else
#ifdef WSAETOOMANYREFS
597
    inscode(d, ds, de, "ETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
598 599
#endif
#endif
600
#ifdef EMFILE
601
    inscode(d, ds, de, "EMFILE", EMFILE, "Too many open files");
602 603
#else
#ifdef WSAEMFILE
604
    inscode(d, ds, de, "EMFILE", WSAEMFILE, "Too many open files");
605
#endif
606 607
#endif
#ifdef ETXTBSY
608
    inscode(d, ds, de, "ETXTBSY", ETXTBSY, "Text file busy");
609 610
#endif
#ifdef EINPROGRESS
611
    inscode(d, ds, de, "EINPROGRESS", EINPROGRESS, "Operation now in progress");
612 613
#else
#ifdef WSAEINPROGRESS
614
    inscode(d, ds, de, "EINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
615 616 617
#endif
#endif
#ifdef ENXIO
618
    inscode(d, ds, de, "ENXIO", ENXIO, "No such device or address");
619 620
#endif
#ifdef ENOPKG
621
    inscode(d, ds, de, "ENOPKG", ENOPKG, "Package not installed");
622
#endif
623
#ifdef WSASY
624
    inscode(d, ds, de, "WSASY", WSASY, "Error WSASY");
625
#endif
626
#ifdef WSAEHOSTDOWN
627
    inscode(d, ds, de, "WSAEHOSTDOWN", WSAEHOSTDOWN, "Host is down");
628
#endif
629
#ifdef WSAENETDOWN
630
    inscode(d, ds, de, "WSAENETDOWN", WSAENETDOWN, "Network is down");
631
#endif
632
#ifdef WSAENOTSOCK
633
    inscode(d, ds, de, "WSAENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
634
#endif
635
#ifdef WSAEHOSTUNREACH
636
    inscode(d, ds, de, "WSAEHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
637
#endif
638
#ifdef WSAELOOP
639
    inscode(d, ds, de, "WSAELOOP", WSAELOOP, "Too many symbolic links encountered");
640
#endif
641
#ifdef WSAEMFILE
642
    inscode(d, ds, de, "WSAEMFILE", WSAEMFILE, "Too many open files");
643
#endif
644
#ifdef WSAESTALE
645
    inscode(d, ds, de, "WSAESTALE", WSAESTALE, "Stale NFS file handle");
646
#endif
647
#ifdef WSAVERNOTSUPPORTED
648
    inscode(d, ds, de, "WSAVERNOTSUPPORTED", WSAVERNOTSUPPORTED, "Error WSAVERNOTSUPPORTED");
649
#endif
650
#ifdef WSAENETUNREACH
651
    inscode(d, ds, de, "WSAENETUNREACH", WSAENETUNREACH, "Network is unreachable");
652
#endif
653
#ifdef WSAEPROCLIM
654
    inscode(d, ds, de, "WSAEPROCLIM", WSAEPROCLIM, "Error WSAEPROCLIM");
655
#endif
656
#ifdef WSAEFAULT
657
    inscode(d, ds, de, "WSAEFAULT", WSAEFAULT, "Bad address");
658
#endif
659
#ifdef WSANOTINITIALISED
660
    inscode(d, ds, de, "WSANOTINITIALISED", WSANOTINITIALISED, "Error WSANOTINITIALISED");
661
#endif
662
#ifdef WSAEUSERS
663
    inscode(d, ds, de, "WSAEUSERS", WSAEUSERS, "Too many users");
664
#endif
665
#ifdef WSAMAKEASYNCREPL
666
    inscode(d, ds, de, "WSAMAKEASYNCREPL", WSAMAKEASYNCREPL, "Error WSAMAKEASYNCREPL");
667
#endif
668
#ifdef WSAENOPROTOOPT
669
    inscode(d, ds, de, "WSAENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
670
#endif
671
#ifdef WSAECONNABORTED
672
    inscode(d, ds, de, "WSAECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
673
#endif
674
#ifdef WSAENAMETOOLONG
675
    inscode(d, ds, de, "WSAENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
676
#endif
677
#ifdef WSAENOTEMPTY
678
    inscode(d, ds, de, "WSAENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
679
#endif
680
#ifdef WSAESHUTDOWN
681
    inscode(d, ds, de, "WSAESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
682
#endif
683
#ifdef WSAEAFNOSUPPORT
684
    inscode(d, ds, de, "WSAEAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
685
#endif
686
#ifdef WSAETOOMANYREFS
687
    inscode(d, ds, de, "WSAETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
688
#endif
689
#ifdef WSAEACCES
690
    inscode(d, ds, de, "WSAEACCES", WSAEACCES, "Permission denied");
691
#endif
692
#ifdef WSATR
693
    inscode(d, ds, de, "WSATR", WSATR, "Error WSATR");
694
#endif
695
#ifdef WSABASEERR
696
    inscode(d, ds, de, "WSABASEERR", WSABASEERR, "Error WSABASEERR");
697
#endif
698
#ifdef WSADESCRIPTIO
699
    inscode(d, ds, de, "WSADESCRIPTIO", WSADESCRIPTIO, "Error WSADESCRIPTIO");
700
#endif
701
#ifdef WSAEMSGSIZE
702
    inscode(d, ds, de, "WSAEMSGSIZE", WSAEMSGSIZE, "Message too long");
703
#endif
704
#ifdef WSAEBADF
705
    inscode(d, ds, de, "WSAEBADF", WSAEBADF, "Bad file number");
706
#endif
707
#ifdef WSAECONNRESET
708
    inscode(d, ds, de, "WSAECONNRESET", WSAECONNRESET, "Connection reset by peer");
709
#endif
710
#ifdef WSAGETSELECTERRO
711
    inscode(d, ds, de, "WSAGETSELECTERRO", WSAGETSELECTERRO, "Error WSAGETSELECTERRO");
712
#endif
713
#ifdef WSAETIMEDOUT
714
    inscode(d, ds, de, "WSAETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
715
#endif
716
#ifdef WSAENOBUFS
717
    inscode(d, ds, de, "WSAENOBUFS", WSAENOBUFS, "No buffer space available");
718
#endif
719
#ifdef WSAEDISCON
720
    inscode(d, ds, de, "WSAEDISCON", WSAEDISCON, "Error WSAEDISCON");
721
#endif
722
#ifdef WSAEINTR
723
    inscode(d, ds, de, "WSAEINTR", WSAEINTR, "Interrupted system call");
724
#endif
725
#ifdef WSAEPROTOTYPE
726
    inscode(d, ds, de, "WSAEPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
727
#endif
728
#ifdef WSAHOS
729
    inscode(d, ds, de, "WSAHOS", WSAHOS, "Error WSAHOS");
730
#endif
731
#ifdef WSAEADDRINUSE
732
    inscode(d, ds, de, "WSAEADDRINUSE", WSAEADDRINUSE, "Address already in use");
733
#endif
734
#ifdef WSAEADDRNOTAVAIL
735
    inscode(d, ds, de, "WSAEADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
736
#endif
737
#ifdef WSAEALREADY
738
    inscode(d, ds, de, "WSAEALREADY", WSAEALREADY, "Operation already in progress");
739
#endif
740
#ifdef WSAEPROTONOSUPPORT
741
    inscode(d, ds, de, "WSAEPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
742
#endif
743
#ifdef WSASYSNOTREADY
744
    inscode(d, ds, de, "WSASYSNOTREADY", WSASYSNOTREADY, "Error WSASYSNOTREADY");
745
#endif
746
#ifdef WSAEWOULDBLOCK
747
    inscode(d, ds, de, "WSAEWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
748
#endif
749
#ifdef WSAEPFNOSUPPORT
750
    inscode(d, ds, de, "WSAEPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
751
#endif
752
#ifdef WSAEOPNOTSUPP
753
    inscode(d, ds, de, "WSAEOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
754
#endif
755
#ifdef WSAEISCONN
756
    inscode(d, ds, de, "WSAEISCONN", WSAEISCONN, "Transport endpoint is already connected");
757
#endif
758
#ifdef WSAEDQUOT
759
    inscode(d, ds, de, "WSAEDQUOT", WSAEDQUOT, "Quota exceeded");
760
#endif
761
#ifdef WSAENOTCONN
762
    inscode(d, ds, de, "WSAENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
763
#endif
764
#ifdef WSAEREMOTE
765
    inscode(d, ds, de, "WSAEREMOTE", WSAEREMOTE, "Object is remote");
766
#endif
767
#ifdef WSAEINVAL
768
    inscode(d, ds, de, "WSAEINVAL", WSAEINVAL, "Invalid argument");
769
#endif
770
#ifdef WSAEINPROGRESS
771
    inscode(d, ds, de, "WSAEINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
772
#endif
773
#ifdef WSAGETSELECTEVEN
774
    inscode(d, ds, de, "WSAGETSELECTEVEN", WSAGETSELECTEVEN, "Error WSAGETSELECTEVEN");
775
#endif
776
#ifdef WSAESOCKTNOSUPPORT
777
    inscode(d, ds, de, "WSAESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
778
#endif
779
#ifdef WSAGETASYNCERRO
780
    inscode(d, ds, de, "WSAGETASYNCERRO", WSAGETASYNCERRO, "Error WSAGETASYNCERRO");
781
#endif
782
#ifdef WSAMAKESELECTREPL
783
    inscode(d, ds, de, "WSAMAKESELECTREPL", WSAMAKESELECTREPL, "Error WSAMAKESELECTREPL");
784
#endif
785
#ifdef WSAGETASYNCBUFLE
786
    inscode(d, ds, de, "WSAGETASYNCBUFLE", WSAGETASYNCBUFLE, "Error WSAGETASYNCBUFLE");
787
#endif
788
#ifdef WSAEDESTADDRREQ
789
    inscode(d, ds, de, "WSAEDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
790
#endif
791
#ifdef WSAECONNREFUSED
792
    inscode(d, ds, de, "WSAECONNREFUSED", WSAECONNREFUSED, "Connection refused");
793 794
#endif
#ifdef WSAENETRESET
795
    inscode(d, ds, de, "WSAENETRESET", WSAENETRESET, "Network dropped connection because of reset");
796
#endif
797
#ifdef WSAN
798
    inscode(d, ds, de, "WSAN", WSAN, "Error WSAN");
799
#endif
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
#ifdef ENOMEDIUM
    inscode(d, ds, de, "ENOMEDIUM", ENOMEDIUM, "No medium found");
#endif
#ifdef EMEDIUMTYPE
    inscode(d, ds, de, "EMEDIUMTYPE", EMEDIUMTYPE, "Wrong medium type");
#endif
#ifdef ECANCELED
    inscode(d, ds, de, "ECANCELED", ECANCELED, "Operation Canceled");
#endif
#ifdef ENOKEY
    inscode(d, ds, de, "ENOKEY", ENOKEY, "Required key not available");
#endif
#ifdef EKEYEXPIRED
    inscode(d, ds, de, "EKEYEXPIRED", EKEYEXPIRED, "Key has expired");
#endif
#ifdef EKEYREVOKED
    inscode(d, ds, de, "EKEYREVOKED", EKEYREVOKED, "Key has been revoked");
#endif
#ifdef EKEYREJECTED
    inscode(d, ds, de, "EKEYREJECTED", EKEYREJECTED, "Key was rejected by service");
#endif
#ifdef EOWNERDEAD
    inscode(d, ds, de, "EOWNERDEAD", EOWNERDEAD, "Owner died");
#endif
#ifdef ENOTRECOVERABLE
    inscode(d, ds, de, "ENOTRECOVERABLE", ENOTRECOVERABLE, "State not recoverable");
#endif
#ifdef ERFKILL
    inscode(d, ds, de, "ERFKILL", ERFKILL, "Operation not possible due to RF-kill");
#endif
830

831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850
    /* Solaris-specific errnos */
#ifdef ECANCELED
    inscode(d, ds, de, "ECANCELED", ECANCELED, "Operation canceled");
#endif
#ifdef ENOTSUP
    inscode(d, ds, de, "ENOTSUP", ENOTSUP, "Operation not supported");
#endif
#ifdef EOWNERDEAD
    inscode(d, ds, de, "EOWNERDEAD", EOWNERDEAD, "Process died with the lock");
#endif
#ifdef ENOTRECOVERABLE
    inscode(d, ds, de, "ENOTRECOVERABLE", ENOTRECOVERABLE, "Lock is not recoverable");
#endif
#ifdef ELOCKUNMAPPED
    inscode(d, ds, de, "ELOCKUNMAPPED", ELOCKUNMAPPED, "Locked lock was unmapped");
#endif
#ifdef ENOTACTIVE
    inscode(d, ds, de, "ENOTACTIVE", ENOTACTIVE, "Facility is not active");
#endif

851 852
    Py_DECREF(de);
    return m;
853
}