Skip to content

Commit c6e5f61

Browse files
committed
reference/micropython/errno: Add errnos and descriptions
Signed-off-by: Jos Verlinde <Jos.Verlinde@microsoft.com>
1 parent 3604617 commit c6e5f61

File tree

1 file changed

+55
-23
lines changed

1 file changed

+55
-23
lines changed

reference/micropython/errno/__init__.pyi

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@ CPython module: :mod:`python:errno` https://docs.python.org/3/library/errno.html
77
88
This module provides access to symbolic error codes for `OSError` exception.
99
A particular inventory of codes depends on :term:`MicroPython port`.
10-
"""
11-
12-
# source version: v1.24.0
13-
# origin module:: repos/micropython/docs/library/errno.rst
14-
from __future__ import annotations
15-
16-
from typing import Dict
17-
18-
from _typeshed import Incomplete
1910
20-
EEXIST: Incomplete
21-
"""\
2211
Error codes, based on ANSI C/POSIX standard. All error codes start with
2312
"E". As mentioned above, inventory of the codes depends on
2413
:term:`MicroPython port`. Errors are usually accessible as ``exc.errno``
@@ -30,19 +19,15 @@ except OSError as exc:
3019
if exc.errno == errno.EEXIST:
3120
print("Directory already exists")
3221
"""
33-
EAGAIN: Incomplete
34-
"""\
35-
Error codes, based on ANSI C/POSIX standard. All error codes start with
36-
"E". As mentioned above, inventory of the codes depends on
37-
:term:`MicroPython port`. Errors are usually accessible as ``exc.errno``
38-
where ``exc`` is an instance of `OSError`. Usage example::
22+
# https://www.thegeekstuff.com/2010/10/linux-error-codes/
23+
24+
# source version: v1.24.0
25+
# origin module:: repos/micropython/docs/library/errno.rst
26+
from __future__ import annotations
27+
28+
from typing import Dict, Final
29+
3930

40-
try:
41-
os.mkdir("my_dir")
42-
except OSError as exc:
43-
if exc.errno == errno.EEXIST:
44-
print("Directory already exists")
45-
"""
4631
errorcode: Dict
4732
"""\
4833
Dictionary mapping numeric error codes to strings with symbolic error
@@ -51,3 +36,50 @@ code (see above)::
5136
>>> print(errno.errorcode[errno.EEXIST])
5237
EEXIST
5338
"""
39+
40+
EPERM: Final[int] = 1
41+
"""Operation not permitted"""
42+
ENOENT: Final[int] = 2
43+
"""No such file or directory"""
44+
EIO: Final[int] = 5
45+
"""I/O error"""
46+
EBADF: Final[int] = 9
47+
"""Bad file descriptor"""
48+
EAGAIN: Final[int] = 11
49+
"""Resource temporarily unavailable"""
50+
ENOMEM: Final[int] = 12
51+
"""Out of memory"""
52+
EACCES: Final[int] = 13
53+
"""Permission denied"""
54+
EEXIST: Final[int] = 17
55+
"""File exists"""
56+
ENODEV: Final[int] = 19
57+
"""No such device"""
58+
EISDIR: Final[int] = 21
59+
"""Is a directory"""
60+
EINVAL: Final[int] = 22
61+
"""Invalid argument"""
62+
EOPNOTSUPP: Final[int] = 95
63+
"""Operation not supported"""
64+
EADDRINUSE: Final[int] = 98
65+
"""Address already in use"""
66+
ECONNABORTED: Final[int] = 103
67+
"""Connection aborted"""
68+
ECONNRESET: Final[int] = 104
69+
"""Connection reset by peer"""
70+
ENOBUFS: Final[int] = 105
71+
"""No buffer space available"""
72+
ENOTCONN: Final[int] = 107
73+
"""Transport endpoint is not connected"""
74+
ETIMEDOUT: Final[int] = 110
75+
"""Connection timed out"""
76+
ECONNREFUSED: Final[int] = 111
77+
"""Connection refused"""
78+
EHOSTUNREACH: Final[int] = 113
79+
"""Host is unreachable"""
80+
EALREADY: Final[int] = 114
81+
"""Operation already in progress"""
82+
EINPROGRESS: Final[int] = 115
83+
"""Operation now in progress"""
84+
ENOTSUP : Final[int] = ...
85+
"""Operation not supported"""

0 commit comments

Comments
 (0)