Skip to content

Commit e47e6ff

Browse files
bpo-41233: Add links to errnos referenced in exceptions docs (GH-21380)
Co-authored-by: Andrew Kuchling <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]> (cherry picked from commit a74892c) Co-authored-by: yyyyyyyan <[email protected]>
1 parent 5b4bc61 commit e47e6ff

File tree

4 files changed

+54
-37
lines changed

4 files changed

+54
-37
lines changed

Doc/library/errno.rst

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This module makes available standard ``errno`` system symbols. The value of each
1010
symbol is the corresponding integer value. The names and descriptions are
11-
borrowed from :file:`linux/include/errno.h`, which should be pretty
11+
borrowed from :file:`linux/include/errno.h`, which should be
1212
all-inclusive.
1313

1414

@@ -27,25 +27,26 @@ defined by the module. The specific list of defined symbols is available as
2727

2828
.. data:: EPERM
2929

30-
Operation not permitted
30+
Operation not permitted. This error is mapped to the exception
31+
:exc:`PermissionError`.
3132

3233

3334
.. data:: ENOENT
3435

35-
No such file or directory
36+
No such file or directory. This error is mapped to the exception
37+
:exc:`FileNotFoundError`.
3638

3739

3840
.. data:: ESRCH
3941

40-
No such process
42+
No such process. This error is mapped to the exception
43+
:exc:`ProcessLookupError`.
4144

4245

4346
.. data:: EINTR
4447

45-
Interrupted system call.
46-
47-
.. seealso::
48-
This error is mapped to the exception :exc:`InterruptedError`.
48+
Interrupted system call. This error is mapped to the exception
49+
:exc:`InterruptedError`.
4950

5051

5152
.. data:: EIO
@@ -75,12 +76,13 @@ defined by the module. The specific list of defined symbols is available as
7576

7677
.. data:: ECHILD
7778

78-
No child processes
79+
No child processes. This error is mapped to the exception
80+
:exc:`ChildProcessError`.
7981

8082

8183
.. data:: EAGAIN
8284

83-
Try again
85+
Try again. This error is mapped to the exception :exc:`BlockingIOError`.
8486

8587

8688
.. data:: ENOMEM
@@ -90,7 +92,8 @@ defined by the module. The specific list of defined symbols is available as
9092

9193
.. data:: EACCES
9294

93-
Permission denied
95+
Permission denied. This error is mapped to the exception
96+
:exc:`PermissionError`.
9497

9598

9699
.. data:: EFAULT
@@ -110,7 +113,8 @@ defined by the module. The specific list of defined symbols is available as
110113

111114
.. data:: EEXIST
112115

113-
File exists
116+
File exists. This error is mapped to the exception
117+
:exc:`FileExistsError`.
114118

115119

116120
.. data:: EXDEV
@@ -125,12 +129,14 @@ defined by the module. The specific list of defined symbols is available as
125129

126130
.. data:: ENOTDIR
127131

128-
Not a directory
132+
Not a directory. This error is mapped to the exception
133+
:exc:`NotADirectoryError`.
129134

130135

131136
.. data:: EISDIR
132137

133-
Is a directory
138+
Is a directory. This error is mapped to the exception
139+
:exc:`IsADirectoryError`.
134140

135141

136142
.. data:: EINVAL
@@ -185,7 +191,8 @@ defined by the module. The specific list of defined symbols is available as
185191

186192
.. data:: EPIPE
187193

188-
Broken pipe
194+
Broken pipe. This error is mapped to the exception
195+
:exc:`BrokenPipeError`.
189196

190197

191198
.. data:: EDOM
@@ -230,7 +237,8 @@ defined by the module. The specific list of defined symbols is available as
230237

231238
.. data:: EWOULDBLOCK
232239

233-
Operation would block
240+
Operation would block. This error is mapped to the exception
241+
:exc:`BlockingIOError`.
234242

235243

236244
.. data:: ENOMSG
@@ -540,12 +548,14 @@ defined by the module. The specific list of defined symbols is available as
540548

541549
.. data:: ECONNABORTED
542550

543-
Software caused connection abort
551+
Software caused connection abort. This error is mapped to the
552+
exception :exc:`ConnectionAbortedError`.
544553

545554

546555
.. data:: ECONNRESET
547556

548-
Connection reset by peer
557+
Connection reset by peer. This error is mapped to the exception
558+
:exc:`ConnectionResetError`.
549559

550560

551561
.. data:: ENOBUFS
@@ -565,7 +575,8 @@ defined by the module. The specific list of defined symbols is available as
565575

566576
.. data:: ESHUTDOWN
567577

568-
Cannot send after transport endpoint shutdown
578+
Cannot send after transport endpoint shutdown. This error is mapped
579+
to the exception :exc:`BrokenPipeError`.
569580

570581

571582
.. data:: ETOOMANYREFS
@@ -575,12 +586,14 @@ defined by the module. The specific list of defined symbols is available as
575586

576587
.. data:: ETIMEDOUT
577588

578-
Connection timed out
589+
Connection timed out. This error is mapped to the exception
590+
:exc:`TimeoutError`.
579591

580592

581593
.. data:: ECONNREFUSED
582594

583-
Connection refused
595+
Connection refused. This error is mapped to the exception
596+
:exc:`ConnectionRefusedError`.
584597

585598

586599
.. data:: EHOSTDOWN
@@ -595,12 +608,14 @@ defined by the module. The specific list of defined symbols is available as
595608

596609
.. data:: EALREADY
597610

598-
Operation already in progress
611+
Operation already in progress. This error is mapped to the
612+
exception :exc:`BlockingIOError`.
599613

600614

601615
.. data:: EINPROGRESS
602616

603-
Operation now in progress
617+
Operation now in progress. This error is mapped to the exception
618+
:exc:`BlockingIOError`.
604619

605620

606621
.. data:: ESTALE

Doc/library/exceptions.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ depending on the system error code.
613613

614614
Raised when an operation would block on an object (e.g. socket) set
615615
for non-blocking operation.
616-
Corresponds to :c:data:`errno` ``EAGAIN``, ``EALREADY``,
617-
``EWOULDBLOCK`` and ``EINPROGRESS``.
616+
Corresponds to :c:data:`errno` :py:data:`~errno.EAGAIN`, :py:data:`~errno.EALREADY`,
617+
:py:data:`~errno.EWOULDBLOCK` and :py:data:`~errno.EINPROGRESS`.
618618

619619
In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have
620620
one more attribute:
@@ -628,7 +628,7 @@ depending on the system error code.
628628
.. exception:: ChildProcessError
629629

630630
Raised when an operation on a child process failed.
631-
Corresponds to :c:data:`errno` ``ECHILD``.
631+
Corresponds to :c:data:`errno` :py:data:`~errno.ECHILD`.
632632

633633
.. exception:: ConnectionError
634634

@@ -642,35 +642,35 @@ depending on the system error code.
642642
A subclass of :exc:`ConnectionError`, raised when trying to write on a
643643
pipe while the other end has been closed, or trying to write on a socket
644644
which has been shutdown for writing.
645-
Corresponds to :c:data:`errno` ``EPIPE`` and ``ESHUTDOWN``.
645+
Corresponds to :c:data:`errno` :py:data:`~errno.EPIPE` and :py:data:`~errno.ESHUTDOWN`.
646646

647647
.. exception:: ConnectionAbortedError
648648

649649
A subclass of :exc:`ConnectionError`, raised when a connection attempt
650650
is aborted by the peer.
651-
Corresponds to :c:data:`errno` ``ECONNABORTED``.
651+
Corresponds to :c:data:`errno` :py:data:`~errno.ECONNABORTED`.
652652

653653
.. exception:: ConnectionRefusedError
654654

655655
A subclass of :exc:`ConnectionError`, raised when a connection attempt
656656
is refused by the peer.
657-
Corresponds to :c:data:`errno` ``ECONNREFUSED``.
657+
Corresponds to :c:data:`errno` :py:data:`~errno.ECONNREFUSED`.
658658

659659
.. exception:: ConnectionResetError
660660

661661
A subclass of :exc:`ConnectionError`, raised when a connection is
662662
reset by the peer.
663-
Corresponds to :c:data:`errno` ``ECONNRESET``.
663+
Corresponds to :c:data:`errno` :py:data:`~errno.ECONNRESET`.
664664

665665
.. exception:: FileExistsError
666666

667667
Raised when trying to create a file or directory which already exists.
668-
Corresponds to :c:data:`errno` ``EEXIST``.
668+
Corresponds to :c:data:`errno` :py:data:`~errno.EEXIST`.
669669

670670
.. exception:: FileNotFoundError
671671

672672
Raised when a file or directory is requested but doesn't exist.
673-
Corresponds to :c:data:`errno` ``ENOENT``.
673+
Corresponds to :c:data:`errno` :py:data:`~errno.ENOENT`.
674674

675675
.. exception:: InterruptedError
676676

@@ -686,31 +686,31 @@ depending on the system error code.
686686

687687
Raised when a file operation (such as :func:`os.remove`) is requested
688688
on a directory.
689-
Corresponds to :c:data:`errno` ``EISDIR``.
689+
Corresponds to :c:data:`errno` :py:data:`~errno.EISDIR`.
690690

691691
.. exception:: NotADirectoryError
692692

693693
Raised when a directory operation (such as :func:`os.listdir`) is requested on
694694
something which is not a directory. On most POSIX platforms, it may also be
695695
raised if an operation attempts to open or traverse a non-directory file as if
696696
it were a directory.
697-
Corresponds to :c:data:`errno` ``ENOTDIR``.
697+
Corresponds to :c:data:`errno` :py:data:`~errno.ENOTDIR`.
698698

699699
.. exception:: PermissionError
700700

701701
Raised when trying to run an operation without the adequate access
702702
rights - for example filesystem permissions.
703-
Corresponds to :c:data:`errno` ``EACCES`` and ``EPERM``.
703+
Corresponds to :c:data:`errno` :py:data:`~errno.EACCES` and :py:data:`~errno.EPERM`.
704704

705705
.. exception:: ProcessLookupError
706706

707707
Raised when a given process doesn't exist.
708-
Corresponds to :c:data:`errno` ``ESRCH``.
708+
Corresponds to :c:data:`errno` :py:data:`~errno.ESRCH`.
709709

710710
.. exception:: TimeoutError
711711

712712
Raised when a system function timed out at the system level.
713-
Corresponds to :c:data:`errno` ``ETIMEDOUT``.
713+
Corresponds to :c:data:`errno` :py:data:`~errno.ETIMEDOUT`.
714714

715715
.. versionadded:: 3.3
716716
All the above :exc:`OSError` subclasses were added.

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@ Ethan Onstott
12691269
Piet van Oostrum
12701270
Tomas Oppelstrup
12711271
Jason Orendorff
1272+
Yan "yyyyyyyan" Orestes
12721273
Bastien Orivel
12731274
orlnub123
12741275
Douglas Orr
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Link the errnos referenced in ``Doc/library/exceptions.rst`` to their respective section in ``Doc/library/errno.rst``, and vice versa. Previously this was only done for EINTR and InterruptedError. Patch by Yan "yyyyyyyan" Orestes.

0 commit comments

Comments
 (0)