Line data Source code
1 :
2 : /* Errno module */
3 :
4 : #include "Python.h"
5 :
6 : /* Windows socket errors (WSA*) */
7 : #ifdef MS_WINDOWS
8 : #define WIN32_LEAN_AND_MEAN
9 : #include <windows.h>
10 : /* The following constants were added to errno.h in VS2010 but have
11 : preferred WSA equivalents. */
12 : #undef EADDRINUSE
13 : #undef EADDRNOTAVAIL
14 : #undef EAFNOSUPPORT
15 : #undef EALREADY
16 : #undef ECONNABORTED
17 : #undef ECONNREFUSED
18 : #undef ECONNRESET
19 : #undef EDESTADDRREQ
20 : #undef EHOSTUNREACH
21 : #undef EINPROGRESS
22 : #undef EISCONN
23 : #undef ELOOP
24 : #undef EMSGSIZE
25 : #undef ENETDOWN
26 : #undef ENETRESET
27 : #undef ENETUNREACH
28 : #undef ENOBUFS
29 : #undef ENOPROTOOPT
30 : #undef ENOTCONN
31 : #undef ENOTSOCK
32 : #undef EOPNOTSUPP
33 : #undef EPROTONOSUPPORT
34 : #undef EPROTOTYPE
35 : #undef ETIMEDOUT
36 : #undef EWOULDBLOCK
37 : #endif
38 :
39 : /*
40 : * Pull in the system error definitions
41 : */
42 :
43 : static PyMethodDef errno_methods[] = {
44 : {NULL, NULL}
45 : };
46 :
47 : /* Helper function doing the dictionary inserting */
48 :
49 : static int
50 223720 : _add_errcode(PyObject *module_dict, PyObject *error_dict, const char *name_str, int code_int)
51 : {
52 223720 : PyObject *name = PyUnicode_FromString(name_str);
53 223720 : if (!name) {
54 0 : return -1;
55 : }
56 :
57 223720 : PyObject *code = PyLong_FromLong(code_int);
58 223720 : if (!code) {
59 0 : Py_DECREF(name);
60 0 : return -1;
61 : }
62 :
63 223720 : int ret = -1;
64 : /* insert in modules dict */
65 223720 : if (PyDict_SetItem(module_dict, name, code) < 0) {
66 0 : goto end;
67 : }
68 : /* insert in errorcode dict */
69 223720 : if (PyDict_SetItem(error_dict, code, name) < 0) {
70 0 : goto end;
71 : }
72 223720 : ret = 0;
73 223720 : end:
74 223720 : Py_DECREF(name);
75 223720 : Py_DECREF(code);
76 223720 : return ret;
77 : }
78 :
79 : static int
80 1645 : errno_exec(PyObject *module)
81 : {
82 1645 : PyObject *module_dict = PyModule_GetDict(module);
83 1645 : PyObject *error_dict = PyDict_New();
84 1645 : if (!module_dict || !error_dict) {
85 0 : return -1;
86 : }
87 1645 : if (PyDict_SetItemString(module_dict, "errorcode", error_dict) < 0) {
88 0 : Py_DECREF(error_dict);
89 0 : return -1;
90 : }
91 :
92 : /* Macro so I don't have to edit each and every line below... */
93 : #define add_errcode(name, code, comment) \
94 : do { \
95 : if (_add_errcode(module_dict, error_dict, name, code) < 0) { \
96 : Py_DECREF(error_dict); \
97 : return -1; \
98 : } \
99 : } while (0);
100 :
101 : /*
102 : * The names and comments are borrowed from linux/include/errno.h,
103 : * which should be pretty all-inclusive. However, the Solaris specific
104 : * names and comments are borrowed from sys/errno.h in Solaris.
105 : * MacOSX specific names and comments are borrowed from sys/errno.h in
106 : * MacOSX.
107 : */
108 :
109 : #ifdef ENODEV
110 1645 : add_errcode("ENODEV", ENODEV, "No such device");
111 : #endif
112 : #ifdef ENOCSI
113 1645 : add_errcode("ENOCSI", ENOCSI, "No CSI structure available");
114 : #endif
115 : #ifdef EHOSTUNREACH
116 1645 : add_errcode("EHOSTUNREACH", EHOSTUNREACH, "No route to host");
117 : #else
118 : #ifdef WSAEHOSTUNREACH
119 : add_errcode("EHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
120 : #endif
121 : #endif
122 : #ifdef ENOMSG
123 1645 : add_errcode("ENOMSG", ENOMSG, "No message of desired type");
124 : #endif
125 : #ifdef EUCLEAN
126 1645 : add_errcode("EUCLEAN", EUCLEAN, "Structure needs cleaning");
127 : #endif
128 : #ifdef EL2NSYNC
129 1645 : add_errcode("EL2NSYNC", EL2NSYNC, "Level 2 not synchronized");
130 : #endif
131 : #ifdef EL2HLT
132 1645 : add_errcode("EL2HLT", EL2HLT, "Level 2 halted");
133 : #endif
134 : #ifdef ENODATA
135 1645 : add_errcode("ENODATA", ENODATA, "No data available");
136 : #endif
137 : #ifdef ENOTBLK
138 1645 : add_errcode("ENOTBLK", ENOTBLK, "Block device required");
139 : #endif
140 : #ifdef ENOSYS
141 1645 : add_errcode("ENOSYS", ENOSYS, "Function not implemented");
142 : #endif
143 : #ifdef EPIPE
144 1645 : add_errcode("EPIPE", EPIPE, "Broken pipe");
145 : #endif
146 : #ifdef EINVAL
147 1645 : add_errcode("EINVAL", EINVAL, "Invalid argument");
148 : #else
149 : #ifdef WSAEINVAL
150 : add_errcode("EINVAL", WSAEINVAL, "Invalid argument");
151 : #endif
152 : #endif
153 : #ifdef EOVERFLOW
154 1645 : add_errcode("EOVERFLOW", EOVERFLOW, "Value too large for defined data type");
155 : #endif
156 : #ifdef EADV
157 1645 : add_errcode("EADV", EADV, "Advertise error");
158 : #endif
159 : #ifdef EINTR
160 1645 : add_errcode("EINTR", EINTR, "Interrupted system call");
161 : #else
162 : #ifdef WSAEINTR
163 : add_errcode("EINTR", WSAEINTR, "Interrupted system call");
164 : #endif
165 : #endif
166 : #ifdef EUSERS
167 1645 : add_errcode("EUSERS", EUSERS, "Too many users");
168 : #else
169 : #ifdef WSAEUSERS
170 : add_errcode("EUSERS", WSAEUSERS, "Too many users");
171 : #endif
172 : #endif
173 : #ifdef ENOTEMPTY
174 1645 : add_errcode("ENOTEMPTY", ENOTEMPTY, "Directory not empty");
175 : #else
176 : #ifdef WSAENOTEMPTY
177 : add_errcode("ENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
178 : #endif
179 : #endif
180 : #ifdef ENOBUFS
181 1645 : add_errcode("ENOBUFS", ENOBUFS, "No buffer space available");
182 : #else
183 : #ifdef WSAENOBUFS
184 : add_errcode("ENOBUFS", WSAENOBUFS, "No buffer space available");
185 : #endif
186 : #endif
187 : #ifdef EPROTO
188 1645 : add_errcode("EPROTO", EPROTO, "Protocol error");
189 : #endif
190 : #ifdef EREMOTE
191 1645 : add_errcode("EREMOTE", EREMOTE, "Object is remote");
192 : #else
193 : #ifdef WSAEREMOTE
194 : add_errcode("EREMOTE", WSAEREMOTE, "Object is remote");
195 : #endif
196 : #endif
197 : #ifdef ENAVAIL
198 1645 : add_errcode("ENAVAIL", ENAVAIL, "No XENIX semaphores available");
199 : #endif
200 : #ifdef ECHILD
201 1645 : add_errcode("ECHILD", ECHILD, "No child processes");
202 : #endif
203 : #ifdef ELOOP
204 1645 : add_errcode("ELOOP", ELOOP, "Too many symbolic links encountered");
205 : #else
206 : #ifdef WSAELOOP
207 : add_errcode("ELOOP", WSAELOOP, "Too many symbolic links encountered");
208 : #endif
209 : #endif
210 : #ifdef EXDEV
211 1645 : add_errcode("EXDEV", EXDEV, "Cross-device link");
212 : #endif
213 : #ifdef E2BIG
214 1645 : add_errcode("E2BIG", E2BIG, "Arg list too long");
215 : #endif
216 : #ifdef ESRCH
217 1645 : add_errcode("ESRCH", ESRCH, "No such process");
218 : #endif
219 : #ifdef EMSGSIZE
220 1645 : add_errcode("EMSGSIZE", EMSGSIZE, "Message too long");
221 : #else
222 : #ifdef WSAEMSGSIZE
223 : add_errcode("EMSGSIZE", WSAEMSGSIZE, "Message too long");
224 : #endif
225 : #endif
226 : #ifdef EAFNOSUPPORT
227 1645 : add_errcode("EAFNOSUPPORT", EAFNOSUPPORT, "Address family not supported by protocol");
228 : #else
229 : #ifdef WSAEAFNOSUPPORT
230 : add_errcode("EAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
231 : #endif
232 : #endif
233 : #ifdef EBADR
234 1645 : add_errcode("EBADR", EBADR, "Invalid request descriptor");
235 : #endif
236 : #ifdef EHOSTDOWN
237 1645 : add_errcode("EHOSTDOWN", EHOSTDOWN, "Host is down");
238 : #else
239 : #ifdef WSAEHOSTDOWN
240 : add_errcode("EHOSTDOWN", WSAEHOSTDOWN, "Host is down");
241 : #endif
242 : #endif
243 : #ifdef EPFNOSUPPORT
244 1645 : add_errcode("EPFNOSUPPORT", EPFNOSUPPORT, "Protocol family not supported");
245 : #else
246 : #ifdef WSAEPFNOSUPPORT
247 : add_errcode("EPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
248 : #endif
249 : #endif
250 : #ifdef ENOPROTOOPT
251 1645 : add_errcode("ENOPROTOOPT", ENOPROTOOPT, "Protocol not available");
252 : #else
253 : #ifdef WSAENOPROTOOPT
254 : add_errcode("ENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
255 : #endif
256 : #endif
257 : #ifdef EBUSY
258 1645 : add_errcode("EBUSY", EBUSY, "Device or resource busy");
259 : #endif
260 : #ifdef EWOULDBLOCK
261 1645 : add_errcode("EWOULDBLOCK", EWOULDBLOCK, "Operation would block");
262 : #else
263 : #ifdef WSAEWOULDBLOCK
264 : add_errcode("EWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
265 : #endif
266 : #endif
267 : #ifdef EBADFD
268 1645 : add_errcode("EBADFD", EBADFD, "File descriptor in bad state");
269 : #endif
270 : #ifdef EDOTDOT
271 1645 : add_errcode("EDOTDOT", EDOTDOT, "RFS specific error");
272 : #endif
273 : #ifdef EISCONN
274 1645 : add_errcode("EISCONN", EISCONN, "Transport endpoint is already connected");
275 : #else
276 : #ifdef WSAEISCONN
277 : add_errcode("EISCONN", WSAEISCONN, "Transport endpoint is already connected");
278 : #endif
279 : #endif
280 : #ifdef ENOANO
281 1645 : add_errcode("ENOANO", ENOANO, "No anode");
282 : #endif
283 : #ifdef ESHUTDOWN
284 1645 : add_errcode("ESHUTDOWN", ESHUTDOWN, "Cannot send after transport endpoint shutdown");
285 : #else
286 : #ifdef WSAESHUTDOWN
287 : add_errcode("ESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
288 : #endif
289 : #endif
290 : #ifdef ECHRNG
291 1645 : add_errcode("ECHRNG", ECHRNG, "Channel number out of range");
292 : #endif
293 : #ifdef ELIBBAD
294 1645 : add_errcode("ELIBBAD", ELIBBAD, "Accessing a corrupted shared library");
295 : #endif
296 : #ifdef ENONET
297 1645 : add_errcode("ENONET", ENONET, "Machine is not on the network");
298 : #endif
299 : #ifdef EBADE
300 1645 : add_errcode("EBADE", EBADE, "Invalid exchange");
301 : #endif
302 : #ifdef EBADF
303 1645 : add_errcode("EBADF", EBADF, "Bad file number");
304 : #else
305 : #ifdef WSAEBADF
306 : add_errcode("EBADF", WSAEBADF, "Bad file number");
307 : #endif
308 : #endif
309 : #ifdef EMULTIHOP
310 1645 : add_errcode("EMULTIHOP", EMULTIHOP, "Multihop attempted");
311 : #endif
312 : #ifdef EIO
313 1645 : add_errcode("EIO", EIO, "I/O error");
314 : #endif
315 : #ifdef EUNATCH
316 1645 : add_errcode("EUNATCH", EUNATCH, "Protocol driver not attached");
317 : #endif
318 : #ifdef EPROTOTYPE
319 1645 : add_errcode("EPROTOTYPE", EPROTOTYPE, "Protocol wrong type for socket");
320 : #else
321 : #ifdef WSAEPROTOTYPE
322 : add_errcode("EPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
323 : #endif
324 : #endif
325 : #ifdef ENOSPC
326 1645 : add_errcode("ENOSPC", ENOSPC, "No space left on device");
327 : #endif
328 : #ifdef ENOEXEC
329 1645 : add_errcode("ENOEXEC", ENOEXEC, "Exec format error");
330 : #endif
331 : #ifdef EALREADY
332 1645 : add_errcode("EALREADY", EALREADY, "Operation already in progress");
333 : #else
334 : #ifdef WSAEALREADY
335 : add_errcode("EALREADY", WSAEALREADY, "Operation already in progress");
336 : #endif
337 : #endif
338 : #ifdef ENETDOWN
339 1645 : add_errcode("ENETDOWN", ENETDOWN, "Network is down");
340 : #else
341 : #ifdef WSAENETDOWN
342 : add_errcode("ENETDOWN", WSAENETDOWN, "Network is down");
343 : #endif
344 : #endif
345 : #ifdef ENOTNAM
346 1645 : add_errcode("ENOTNAM", ENOTNAM, "Not a XENIX named type file");
347 : #endif
348 : #ifdef EACCES
349 1645 : add_errcode("EACCES", EACCES, "Permission denied");
350 : #else
351 : #ifdef WSAEACCES
352 : add_errcode("EACCES", WSAEACCES, "Permission denied");
353 : #endif
354 : #endif
355 : #ifdef ELNRNG
356 1645 : add_errcode("ELNRNG", ELNRNG, "Link number out of range");
357 : #endif
358 : #ifdef EILSEQ
359 1645 : add_errcode("EILSEQ", EILSEQ, "Illegal byte sequence");
360 : #endif
361 : #ifdef ENOTDIR
362 1645 : add_errcode("ENOTDIR", ENOTDIR, "Not a directory");
363 : #endif
364 : #ifdef ENOTUNIQ
365 1645 : add_errcode("ENOTUNIQ", ENOTUNIQ, "Name not unique on network");
366 : #endif
367 : #ifdef EPERM
368 1645 : add_errcode("EPERM", EPERM, "Operation not permitted");
369 : #endif
370 : #ifdef EDOM
371 1645 : add_errcode("EDOM", EDOM, "Math argument out of domain of func");
372 : #endif
373 : #ifdef EXFULL
374 1645 : add_errcode("EXFULL", EXFULL, "Exchange full");
375 : #endif
376 : #ifdef ECONNREFUSED
377 1645 : add_errcode("ECONNREFUSED", ECONNREFUSED, "Connection refused");
378 : #else
379 : #ifdef WSAECONNREFUSED
380 : add_errcode("ECONNREFUSED", WSAECONNREFUSED, "Connection refused");
381 : #endif
382 : #endif
383 : #ifdef EISDIR
384 1645 : add_errcode("EISDIR", EISDIR, "Is a directory");
385 : #endif
386 : #ifdef EPROTONOSUPPORT
387 1645 : add_errcode("EPROTONOSUPPORT", EPROTONOSUPPORT, "Protocol not supported");
388 : #else
389 : #ifdef WSAEPROTONOSUPPORT
390 : add_errcode("EPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
391 : #endif
392 : #endif
393 : #ifdef EROFS
394 1645 : add_errcode("EROFS", EROFS, "Read-only file system");
395 : #endif
396 : #ifdef EADDRNOTAVAIL
397 1645 : add_errcode("EADDRNOTAVAIL", EADDRNOTAVAIL, "Cannot assign requested address");
398 : #else
399 : #ifdef WSAEADDRNOTAVAIL
400 : add_errcode("EADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
401 : #endif
402 : #endif
403 : #ifdef EIDRM
404 1645 : add_errcode("EIDRM", EIDRM, "Identifier removed");
405 : #endif
406 : #ifdef ECOMM
407 1645 : add_errcode("ECOMM", ECOMM, "Communication error on send");
408 : #endif
409 : #ifdef ESRMNT
410 1645 : add_errcode("ESRMNT", ESRMNT, "Srmount error");
411 : #endif
412 : #ifdef EREMOTEIO
413 1645 : add_errcode("EREMOTEIO", EREMOTEIO, "Remote I/O error");
414 : #endif
415 : #ifdef EL3RST
416 1645 : add_errcode("EL3RST", EL3RST, "Level 3 reset");
417 : #endif
418 : #ifdef EBADMSG
419 1645 : add_errcode("EBADMSG", EBADMSG, "Not a data message");
420 : #endif
421 : #ifdef ENFILE
422 1645 : add_errcode("ENFILE", ENFILE, "File table overflow");
423 : #endif
424 : #ifdef ELIBMAX
425 1645 : add_errcode("ELIBMAX", ELIBMAX, "Attempting to link in too many shared libraries");
426 : #endif
427 : #ifdef ESPIPE
428 1645 : add_errcode("ESPIPE", ESPIPE, "Illegal seek");
429 : #endif
430 : #ifdef ENOLINK
431 1645 : add_errcode("ENOLINK", ENOLINK, "Link has been severed");
432 : #endif
433 : #ifdef ENETRESET
434 1645 : add_errcode("ENETRESET", ENETRESET, "Network dropped connection because of reset");
435 : #else
436 : #ifdef WSAENETRESET
437 : add_errcode("ENETRESET", WSAENETRESET, "Network dropped connection because of reset");
438 : #endif
439 : #endif
440 : #ifdef ETIMEDOUT
441 1645 : add_errcode("ETIMEDOUT", ETIMEDOUT, "Connection timed out");
442 : #else
443 : #ifdef WSAETIMEDOUT
444 : add_errcode("ETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
445 : #endif
446 : #endif
447 : #ifdef ENOENT
448 1645 : add_errcode("ENOENT", ENOENT, "No such file or directory");
449 : #endif
450 : #ifdef EEXIST
451 1645 : add_errcode("EEXIST", EEXIST, "File exists");
452 : #endif
453 : #ifdef EDQUOT
454 1645 : add_errcode("EDQUOT", EDQUOT, "Quota exceeded");
455 : #else
456 : #ifdef WSAEDQUOT
457 : add_errcode("EDQUOT", WSAEDQUOT, "Quota exceeded");
458 : #endif
459 : #endif
460 : #ifdef ENOSTR
461 1645 : add_errcode("ENOSTR", ENOSTR, "Device not a stream");
462 : #endif
463 : #ifdef EBADSLT
464 1645 : add_errcode("EBADSLT", EBADSLT, "Invalid slot");
465 : #endif
466 : #ifdef EBADRQC
467 1645 : add_errcode("EBADRQC", EBADRQC, "Invalid request code");
468 : #endif
469 : #ifdef ELIBACC
470 1645 : add_errcode("ELIBACC", ELIBACC, "Can not access a needed shared library");
471 : #endif
472 : #ifdef EFAULT
473 1645 : add_errcode("EFAULT", EFAULT, "Bad address");
474 : #else
475 : #ifdef WSAEFAULT
476 : add_errcode("EFAULT", WSAEFAULT, "Bad address");
477 : #endif
478 : #endif
479 : #ifdef EFBIG
480 1645 : add_errcode("EFBIG", EFBIG, "File too large");
481 : #endif
482 : #ifdef EDEADLK
483 1645 : add_errcode("EDEADLK", EDEADLK, "Resource deadlock would occur");
484 : #endif
485 : #ifdef ENOTCONN
486 1645 : add_errcode("ENOTCONN", ENOTCONN, "Transport endpoint is not connected");
487 : #else
488 : #ifdef WSAENOTCONN
489 : add_errcode("ENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
490 : #endif
491 : #endif
492 : #ifdef EDESTADDRREQ
493 1645 : add_errcode("EDESTADDRREQ", EDESTADDRREQ, "Destination address required");
494 : #else
495 : #ifdef WSAEDESTADDRREQ
496 : add_errcode("EDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
497 : #endif
498 : #endif
499 : #ifdef ELIBSCN
500 1645 : add_errcode("ELIBSCN", ELIBSCN, ".lib section in a.out corrupted");
501 : #endif
502 : #ifdef ENOLCK
503 1645 : add_errcode("ENOLCK", ENOLCK, "No record locks available");
504 : #endif
505 : #ifdef EISNAM
506 1645 : add_errcode("EISNAM", EISNAM, "Is a named type file");
507 : #endif
508 : #ifdef ECONNABORTED
509 1645 : add_errcode("ECONNABORTED", ECONNABORTED, "Software caused connection abort");
510 : #else
511 : #ifdef WSAECONNABORTED
512 : add_errcode("ECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
513 : #endif
514 : #endif
515 : #ifdef ENETUNREACH
516 1645 : add_errcode("ENETUNREACH", ENETUNREACH, "Network is unreachable");
517 : #else
518 : #ifdef WSAENETUNREACH
519 : add_errcode("ENETUNREACH", WSAENETUNREACH, "Network is unreachable");
520 : #endif
521 : #endif
522 : #ifdef ESTALE
523 1645 : add_errcode("ESTALE", ESTALE, "Stale NFS file handle");
524 : #else
525 : #ifdef WSAESTALE
526 : add_errcode("ESTALE", WSAESTALE, "Stale NFS file handle");
527 : #endif
528 : #endif
529 : #ifdef ENOSR
530 1645 : add_errcode("ENOSR", ENOSR, "Out of streams resources");
531 : #endif
532 : #ifdef ENOMEM
533 1645 : add_errcode("ENOMEM", ENOMEM, "Out of memory");
534 : #endif
535 : #ifdef ENOTSOCK
536 1645 : add_errcode("ENOTSOCK", ENOTSOCK, "Socket operation on non-socket");
537 : #else
538 : #ifdef WSAENOTSOCK
539 : add_errcode("ENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
540 : #endif
541 : #endif
542 : #ifdef ESTRPIPE
543 1645 : add_errcode("ESTRPIPE", ESTRPIPE, "Streams pipe error");
544 : #endif
545 : #ifdef EMLINK
546 1645 : add_errcode("EMLINK", EMLINK, "Too many links");
547 : #endif
548 : #ifdef ERANGE
549 1645 : add_errcode("ERANGE", ERANGE, "Math result not representable");
550 : #endif
551 : #ifdef ELIBEXEC
552 1645 : add_errcode("ELIBEXEC", ELIBEXEC, "Cannot exec a shared library directly");
553 : #endif
554 : #ifdef EL3HLT
555 1645 : add_errcode("EL3HLT", EL3HLT, "Level 3 halted");
556 : #endif
557 : #ifdef ECONNRESET
558 1645 : add_errcode("ECONNRESET", ECONNRESET, "Connection reset by peer");
559 : #else
560 : #ifdef WSAECONNRESET
561 : add_errcode("ECONNRESET", WSAECONNRESET, "Connection reset by peer");
562 : #endif
563 : #endif
564 : #ifdef EADDRINUSE
565 1645 : add_errcode("EADDRINUSE", EADDRINUSE, "Address already in use");
566 : #else
567 : #ifdef WSAEADDRINUSE
568 : add_errcode("EADDRINUSE", WSAEADDRINUSE, "Address already in use");
569 : #endif
570 : #endif
571 : #ifdef EOPNOTSUPP
572 1645 : add_errcode("EOPNOTSUPP", EOPNOTSUPP, "Operation not supported on transport endpoint");
573 : #else
574 : #ifdef WSAEOPNOTSUPP
575 : add_errcode("EOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
576 : #endif
577 : #endif
578 : #ifdef EREMCHG
579 1645 : add_errcode("EREMCHG", EREMCHG, "Remote address changed");
580 : #endif
581 : #ifdef EAGAIN
582 1645 : add_errcode("EAGAIN", EAGAIN, "Try again");
583 : #endif
584 : #ifdef ENAMETOOLONG
585 1645 : add_errcode("ENAMETOOLONG", ENAMETOOLONG, "File name too long");
586 : #else
587 : #ifdef WSAENAMETOOLONG
588 : add_errcode("ENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
589 : #endif
590 : #endif
591 : #ifdef ENOTTY
592 1645 : add_errcode("ENOTTY", ENOTTY, "Not a typewriter");
593 : #endif
594 : #ifdef ERESTART
595 1645 : add_errcode("ERESTART", ERESTART, "Interrupted system call should be restarted");
596 : #endif
597 : #ifdef ESOCKTNOSUPPORT
598 1645 : add_errcode("ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, "Socket type not supported");
599 : #else
600 : #ifdef WSAESOCKTNOSUPPORT
601 : add_errcode("ESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
602 : #endif
603 : #endif
604 : #ifdef ETIME
605 1645 : add_errcode("ETIME", ETIME, "Timer expired");
606 : #endif
607 : #ifdef EBFONT
608 1645 : add_errcode("EBFONT", EBFONT, "Bad font file format");
609 : #endif
610 : #ifdef EDEADLOCK
611 1645 : add_errcode("EDEADLOCK", EDEADLOCK, "Error EDEADLOCK");
612 : #endif
613 : #ifdef ETOOMANYREFS
614 1645 : add_errcode("ETOOMANYREFS", ETOOMANYREFS, "Too many references: cannot splice");
615 : #else
616 : #ifdef WSAETOOMANYREFS
617 : add_errcode("ETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
618 : #endif
619 : #endif
620 : #ifdef EMFILE
621 1645 : add_errcode("EMFILE", EMFILE, "Too many open files");
622 : #else
623 : #ifdef WSAEMFILE
624 : add_errcode("EMFILE", WSAEMFILE, "Too many open files");
625 : #endif
626 : #endif
627 : #ifdef ETXTBSY
628 1645 : add_errcode("ETXTBSY", ETXTBSY, "Text file busy");
629 : #endif
630 : #ifdef EINPROGRESS
631 1645 : add_errcode("EINPROGRESS", EINPROGRESS, "Operation now in progress");
632 : #else
633 : #ifdef WSAEINPROGRESS
634 : add_errcode("EINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
635 : #endif
636 : #endif
637 : #ifdef ENXIO
638 1645 : add_errcode("ENXIO", ENXIO, "No such device or address");
639 : #endif
640 : #ifdef ENOPKG
641 1645 : add_errcode("ENOPKG", ENOPKG, "Package not installed");
642 : #endif
643 : #ifdef WSASY
644 : add_errcode("WSASY", WSASY, "Error WSASY");
645 : #endif
646 : #ifdef WSAEHOSTDOWN
647 : add_errcode("WSAEHOSTDOWN", WSAEHOSTDOWN, "Host is down");
648 : #endif
649 : #ifdef WSAENETDOWN
650 : add_errcode("WSAENETDOWN", WSAENETDOWN, "Network is down");
651 : #endif
652 : #ifdef WSAENOTSOCK
653 : add_errcode("WSAENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
654 : #endif
655 : #ifdef WSAEHOSTUNREACH
656 : add_errcode("WSAEHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
657 : #endif
658 : #ifdef WSAELOOP
659 : add_errcode("WSAELOOP", WSAELOOP, "Too many symbolic links encountered");
660 : #endif
661 : #ifdef WSAEMFILE
662 : add_errcode("WSAEMFILE", WSAEMFILE, "Too many open files");
663 : #endif
664 : #ifdef WSAESTALE
665 : add_errcode("WSAESTALE", WSAESTALE, "Stale NFS file handle");
666 : #endif
667 : #ifdef WSAVERNOTSUPPORTED
668 : add_errcode("WSAVERNOTSUPPORTED", WSAVERNOTSUPPORTED, "Error WSAVERNOTSUPPORTED");
669 : #endif
670 : #ifdef WSAENETUNREACH
671 : add_errcode("WSAENETUNREACH", WSAENETUNREACH, "Network is unreachable");
672 : #endif
673 : #ifdef WSAEPROCLIM
674 : add_errcode("WSAEPROCLIM", WSAEPROCLIM, "Error WSAEPROCLIM");
675 : #endif
676 : #ifdef WSAEFAULT
677 : add_errcode("WSAEFAULT", WSAEFAULT, "Bad address");
678 : #endif
679 : #ifdef WSANOTINITIALISED
680 : add_errcode("WSANOTINITIALISED", WSANOTINITIALISED, "Error WSANOTINITIALISED");
681 : #endif
682 : #ifdef WSAEUSERS
683 : add_errcode("WSAEUSERS", WSAEUSERS, "Too many users");
684 : #endif
685 : #ifdef WSAMAKEASYNCREPL
686 : add_errcode("WSAMAKEASYNCREPL", WSAMAKEASYNCREPL, "Error WSAMAKEASYNCREPL");
687 : #endif
688 : #ifdef WSAENOPROTOOPT
689 : add_errcode("WSAENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
690 : #endif
691 : #ifdef WSAECONNABORTED
692 : add_errcode("WSAECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
693 : #endif
694 : #ifdef WSAENAMETOOLONG
695 : add_errcode("WSAENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
696 : #endif
697 : #ifdef WSAENOTEMPTY
698 : add_errcode("WSAENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
699 : #endif
700 : #ifdef WSAESHUTDOWN
701 : add_errcode("WSAESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
702 : #endif
703 : #ifdef WSAEAFNOSUPPORT
704 : add_errcode("WSAEAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
705 : #endif
706 : #ifdef WSAETOOMANYREFS
707 : add_errcode("WSAETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
708 : #endif
709 : #ifdef WSAEACCES
710 : add_errcode("WSAEACCES", WSAEACCES, "Permission denied");
711 : #endif
712 : #ifdef WSATR
713 : add_errcode("WSATR", WSATR, "Error WSATR");
714 : #endif
715 : #ifdef WSABASEERR
716 : add_errcode("WSABASEERR", WSABASEERR, "Error WSABASEERR");
717 : #endif
718 : #ifdef WSADESCRIPTIO
719 : add_errcode("WSADESCRIPTIO", WSADESCRIPTIO, "Error WSADESCRIPTIO");
720 : #endif
721 : #ifdef WSAEMSGSIZE
722 : add_errcode("WSAEMSGSIZE", WSAEMSGSIZE, "Message too long");
723 : #endif
724 : #ifdef WSAEBADF
725 : add_errcode("WSAEBADF", WSAEBADF, "Bad file number");
726 : #endif
727 : #ifdef WSAECONNRESET
728 : add_errcode("WSAECONNRESET", WSAECONNRESET, "Connection reset by peer");
729 : #endif
730 : #ifdef WSAGETSELECTERRO
731 : add_errcode("WSAGETSELECTERRO", WSAGETSELECTERRO, "Error WSAGETSELECTERRO");
732 : #endif
733 : #ifdef WSAETIMEDOUT
734 : add_errcode("WSAETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
735 : #endif
736 : #ifdef WSAENOBUFS
737 : add_errcode("WSAENOBUFS", WSAENOBUFS, "No buffer space available");
738 : #endif
739 : #ifdef WSAEDISCON
740 : add_errcode("WSAEDISCON", WSAEDISCON, "Error WSAEDISCON");
741 : #endif
742 : #ifdef WSAEINTR
743 : add_errcode("WSAEINTR", WSAEINTR, "Interrupted system call");
744 : #endif
745 : #ifdef WSAEPROTOTYPE
746 : add_errcode("WSAEPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
747 : #endif
748 : #ifdef WSAHOS
749 : add_errcode("WSAHOS", WSAHOS, "Error WSAHOS");
750 : #endif
751 : #ifdef WSAEADDRINUSE
752 : add_errcode("WSAEADDRINUSE", WSAEADDRINUSE, "Address already in use");
753 : #endif
754 : #ifdef WSAEADDRNOTAVAIL
755 : add_errcode("WSAEADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
756 : #endif
757 : #ifdef WSAEALREADY
758 : add_errcode("WSAEALREADY", WSAEALREADY, "Operation already in progress");
759 : #endif
760 : #ifdef WSAEPROTONOSUPPORT
761 : add_errcode("WSAEPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
762 : #endif
763 : #ifdef WSASYSNOTREADY
764 : add_errcode("WSASYSNOTREADY", WSASYSNOTREADY, "Error WSASYSNOTREADY");
765 : #endif
766 : #ifdef WSAEWOULDBLOCK
767 : add_errcode("WSAEWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
768 : #endif
769 : #ifdef WSAEPFNOSUPPORT
770 : add_errcode("WSAEPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
771 : #endif
772 : #ifdef WSAEOPNOTSUPP
773 : add_errcode("WSAEOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
774 : #endif
775 : #ifdef WSAEISCONN
776 : add_errcode("WSAEISCONN", WSAEISCONN, "Transport endpoint is already connected");
777 : #endif
778 : #ifdef WSAEDQUOT
779 : add_errcode("WSAEDQUOT", WSAEDQUOT, "Quota exceeded");
780 : #endif
781 : #ifdef WSAENOTCONN
782 : add_errcode("WSAENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
783 : #endif
784 : #ifdef WSAEREMOTE
785 : add_errcode("WSAEREMOTE", WSAEREMOTE, "Object is remote");
786 : #endif
787 : #ifdef WSAEINVAL
788 : add_errcode("WSAEINVAL", WSAEINVAL, "Invalid argument");
789 : #endif
790 : #ifdef WSAEINPROGRESS
791 : add_errcode("WSAEINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
792 : #endif
793 : #ifdef WSAGETSELECTEVEN
794 : add_errcode("WSAGETSELECTEVEN", WSAGETSELECTEVEN, "Error WSAGETSELECTEVEN");
795 : #endif
796 : #ifdef WSAESOCKTNOSUPPORT
797 : add_errcode("WSAESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
798 : #endif
799 : #ifdef WSAGETASYNCERRO
800 : add_errcode("WSAGETASYNCERRO", WSAGETASYNCERRO, "Error WSAGETASYNCERRO");
801 : #endif
802 : #ifdef WSAMAKESELECTREPL
803 : add_errcode("WSAMAKESELECTREPL", WSAMAKESELECTREPL, "Error WSAMAKESELECTREPL");
804 : #endif
805 : #ifdef WSAGETASYNCBUFLE
806 : add_errcode("WSAGETASYNCBUFLE", WSAGETASYNCBUFLE, "Error WSAGETASYNCBUFLE");
807 : #endif
808 : #ifdef WSAEDESTADDRREQ
809 : add_errcode("WSAEDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
810 : #endif
811 : #ifdef WSAECONNREFUSED
812 : add_errcode("WSAECONNREFUSED", WSAECONNREFUSED, "Connection refused");
813 : #endif
814 : #ifdef WSAENETRESET
815 : add_errcode("WSAENETRESET", WSAENETRESET, "Network dropped connection because of reset");
816 : #endif
817 : #ifdef WSAN
818 : add_errcode("WSAN", WSAN, "Error WSAN");
819 : #endif
820 : #ifdef ENOMEDIUM
821 1645 : add_errcode("ENOMEDIUM", ENOMEDIUM, "No medium found");
822 : #endif
823 : #ifdef EMEDIUMTYPE
824 1645 : add_errcode("EMEDIUMTYPE", EMEDIUMTYPE, "Wrong medium type");
825 : #endif
826 : #ifdef ECANCELED
827 1645 : add_errcode("ECANCELED", ECANCELED, "Operation Canceled");
828 : #endif
829 : #ifdef ENOKEY
830 1645 : add_errcode("ENOKEY", ENOKEY, "Required key not available");
831 : #endif
832 : #ifdef EKEYEXPIRED
833 1645 : add_errcode("EKEYEXPIRED", EKEYEXPIRED, "Key has expired");
834 : #endif
835 : #ifdef EKEYREVOKED
836 1645 : add_errcode("EKEYREVOKED", EKEYREVOKED, "Key has been revoked");
837 : #endif
838 : #ifdef EKEYREJECTED
839 1645 : add_errcode("EKEYREJECTED", EKEYREJECTED, "Key was rejected by service");
840 : #endif
841 : #ifdef EOWNERDEAD
842 1645 : add_errcode("EOWNERDEAD", EOWNERDEAD, "Owner died");
843 : #endif
844 : #ifdef ENOTRECOVERABLE
845 1645 : add_errcode("ENOTRECOVERABLE", ENOTRECOVERABLE, "State not recoverable");
846 : #endif
847 : #ifdef ERFKILL
848 1645 : add_errcode("ERFKILL", ERFKILL, "Operation not possible due to RF-kill");
849 : #endif
850 :
851 : /* Solaris-specific errnos */
852 : #ifdef ECANCELED
853 1645 : add_errcode("ECANCELED", ECANCELED, "Operation canceled");
854 : #endif
855 : #ifdef ENOTSUP
856 1645 : add_errcode("ENOTSUP", ENOTSUP, "Operation not supported");
857 : #endif
858 : #ifdef EOWNERDEAD
859 1645 : add_errcode("EOWNERDEAD", EOWNERDEAD, "Process died with the lock");
860 : #endif
861 : #ifdef ENOTRECOVERABLE
862 1645 : add_errcode("ENOTRECOVERABLE", ENOTRECOVERABLE, "Lock is not recoverable");
863 : #endif
864 : #ifdef ELOCKUNMAPPED
865 : add_errcode("ELOCKUNMAPPED", ELOCKUNMAPPED, "Locked lock was unmapped");
866 : #endif
867 : #ifdef ENOTACTIVE
868 : add_errcode("ENOTACTIVE", ENOTACTIVE, "Facility is not active");
869 : #endif
870 :
871 : /* MacOSX specific errnos */
872 : #ifdef EAUTH
873 : add_errcode("EAUTH", EAUTH, "Authentication error");
874 : #endif
875 : #ifdef EBADARCH
876 : add_errcode("EBADARCH", EBADARCH, "Bad CPU type in executable");
877 : #endif
878 : #ifdef EBADEXEC
879 : add_errcode("EBADEXEC", EBADEXEC, "Bad executable (or shared library)");
880 : #endif
881 : #ifdef EBADMACHO
882 : add_errcode("EBADMACHO", EBADMACHO, "Malformed Mach-o file");
883 : #endif
884 : #ifdef EBADRPC
885 : add_errcode("EBADRPC", EBADRPC, "RPC struct is bad");
886 : #endif
887 : #ifdef EDEVERR
888 : add_errcode("EDEVERR", EDEVERR, "Device error");
889 : #endif
890 : #ifdef EFTYPE
891 : add_errcode("EFTYPE", EFTYPE, "Inappropriate file type or format");
892 : #endif
893 : #ifdef ENEEDAUTH
894 : add_errcode("ENEEDAUTH", ENEEDAUTH, "Need authenticator");
895 : #endif
896 : #ifdef ENOATTR
897 : add_errcode("ENOATTR", ENOATTR, "Attribute not found");
898 : #endif
899 : #ifdef ENOPOLICY
900 : add_errcode("ENOPOLICY", ENOPOLICY, "Policy not found");
901 : #endif
902 : #ifdef EPROCLIM
903 : add_errcode("EPROCLIM", EPROCLIM, "Too many processes");
904 : #endif
905 : #ifdef EPROCUNAVAIL
906 : add_errcode("EPROCUNAVAIL", EPROCUNAVAIL, "Bad procedure for program");
907 : #endif
908 : #ifdef EPROGMISMATCH
909 : add_errcode("EPROGMISMATCH", EPROGMISMATCH, "Program version wrong");
910 : #endif
911 : #ifdef EPROGUNAVAIL
912 : add_errcode("EPROGUNAVAIL", EPROGUNAVAIL, "RPC prog. not avail");
913 : #endif
914 : #ifdef EPWROFF
915 : add_errcode("EPWROFF", EPWROFF, "Device power is off");
916 : #endif
917 : #ifdef ERPCMISMATCH
918 : add_errcode("ERPCMISMATCH", ERPCMISMATCH, "RPC version wrong");
919 : #endif
920 : #ifdef ESHLIBVERS
921 : add_errcode("ESHLIBVERS", ESHLIBVERS, "Shared library version mismatch");
922 : #endif
923 : #ifdef EQFULL
924 : add_errcode("EQFULL", EQFULL, "Interface output queue is full");
925 : #endif
926 :
927 1645 : Py_DECREF(error_dict);
928 1645 : return 0;
929 : }
930 :
931 : static PyModuleDef_Slot errno_slots[] = {
932 : {Py_mod_exec, errno_exec},
933 : {0, NULL}
934 : };
935 :
936 : PyDoc_STRVAR(errno__doc__,
937 : "This module makes available standard errno system symbols.\n\
938 : \n\
939 : The value of each symbol is the corresponding integer value,\n\
940 : e.g., on most systems, errno.ENOENT equals the integer 2.\n\
941 : \n\
942 : The dictionary errno.errorcode maps numeric codes to symbol names,\n\
943 : e.g., errno.errorcode[2] could be the string 'ENOENT'.\n\
944 : \n\
945 : Symbols that are not relevant to the underlying system are not defined.\n\
946 : \n\
947 : To map error codes to error messages, use the function os.strerror(),\n\
948 : e.g. os.strerror(2) could return 'No such file or directory'.");
949 :
950 : static struct PyModuleDef errnomodule = {
951 : PyModuleDef_HEAD_INIT,
952 : .m_name = "errno",
953 : .m_doc = errno__doc__,
954 : .m_size = 0,
955 : .m_methods = errno_methods,
956 : .m_slots = errno_slots,
957 : };
958 :
959 : PyMODINIT_FUNC
960 1645 : PyInit_errno(void)
961 : {
962 1645 : return PyModuleDef_Init(&errnomodule);
963 : }
|