You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

935 lines
28 KiB

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