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