Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 690a6a9

Browse files
Issue #19207: Improved cross-references in the os, os.path, and posix modules
documentation.
2 parents 10e73ba + dab8354 commit 690a6a9

3 files changed

Lines changed: 37 additions & 35 deletions

File tree

Doc/library/os.path.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ the :mod:`glob` module.)
271271
.. function:: samestat(stat1, stat2)
272272

273273
Return ``True`` if the stat tuples *stat1* and *stat2* refer to the same file.
274-
These structures may have been returned by :func:`fstat`, :func:`lstat`, or
275-
:func:`stat`. This function implements the underlying comparison used by
276-
:func:`samefile` and :func:`sameopenfile`.
274+
These structures may have been returned by :func:`os.fstat`,
275+
:func:`os.lstat`, or :func:`os.stat`. This function implements the
276+
underlying comparison used by :func:`samefile` and :func:`sameopenfile`.
277277

278278
Availability: Unix, Windows.
279279

Doc/library/os.rst

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ process will then be assigned 3, 4, 5, and so forth. The name "file descriptor"
643643
is slightly deceptive; on Unix platforms, sockets and pipes are also referenced
644644
by file descriptors.
645645

646-
The :meth:`~file.fileno` method can be used to obtain the file descriptor
646+
The :meth:`~io.IOBase.fileno` method can be used to obtain the file descriptor
647647
associated with a :term:`file object` when required. Note that using the file
648648
descriptor directly will bypass the file object methods, ignoring aspects such
649649
as internal buffering of data.
@@ -660,7 +660,7 @@ as internal buffering of data.
660660
This function is intended for low-level I/O and must be applied to a file
661661
descriptor as returned by :func:`os.open` or :func:`pipe`. To close a "file
662662
object" returned by the built-in function :func:`open` or by :func:`popen` or
663-
:func:`fdopen`, use its :meth:`~file.close` method.
663+
:func:`fdopen`, use its :meth:`~io.IOBase.close` method.
664664

665665

666666
.. function:: closerange(fd_low, fd_high)
@@ -834,7 +834,7 @@ as internal buffering of data.
834834
Set the current position of file descriptor *fd* to position *pos*, modified
835835
by *how*: :const:`SEEK_SET` or ``0`` to set the position relative to the
836836
beginning of the file; :const:`SEEK_CUR` or ``1`` to set it relative to the
837-
current position; :const:`os.SEEK_END` or ``2`` to set it relative to the end of
837+
current position; :const:`SEEK_END` or ``2`` to set it relative to the end of
838838
the file. Return the new cursor position in bytes, starting from the beginning.
839839

840840
Availability: Unix, Windows.
@@ -1217,7 +1217,7 @@ execution of a new program, other file descriptors are inherited.
12171217

12181218
On Windows, non-inheritable handles and file descriptors are closed in child
12191219
processes, except for standard streams (file descriptors 0, 1 and 2: stdin, stdout
1220-
and stderr), which are always inherited. Using :func:`os.spawn*` functions,
1220+
and stderr), which are always inherited. Using :func:`spawn\* <spawnl>` functions,
12211221
all inheritable handles and all inheritable file descriptors are inherited.
12221222
Using the :mod:`subprocess` module, all file descriptors except standard
12231223
streams are closed, and inheritable handles are only inherited if the
@@ -1993,7 +1993,7 @@ features:
19931993

19941994
.. data:: supports_dir_fd
19951995

1996-
A :class:`~collections.Set` object indicating which functions in the
1996+
A :class:`~collections.abc.Set` object indicating which functions in the
19971997
:mod:`os` module permit use of their *dir_fd* parameter. Different platforms
19981998
provide different functionality, and an option that might work on one might
19991999
be unsupported on another. For consistency's sakes, functions that support
@@ -2015,7 +2015,7 @@ features:
20152015

20162016
.. data:: supports_effective_ids
20172017

2018-
A :class:`~collections.Set` object indicating which functions in the
2018+
A :class:`~collections.abc.Set` object indicating which functions in the
20192019
:mod:`os` module permit use of the *effective_ids* parameter for
20202020
:func:`os.access`. If the local platform supports it, the collection will
20212021
contain :func:`os.access`, otherwise it will be empty.
@@ -2033,7 +2033,7 @@ features:
20332033

20342034
.. data:: supports_fd
20352035

2036-
A :class:`~collections.Set` object indicating which functions in the
2036+
A :class:`~collections.abc.Set` object indicating which functions in the
20372037
:mod:`os` module permit specifying their *path* parameter as an open file
20382038
descriptor. Different platforms provide different functionality, and an
20392039
option that might work on one might be unsupported on another. For
@@ -2054,7 +2054,7 @@ features:
20542054

20552055
.. data:: supports_follow_symlinks
20562056

2057-
A :class:`~collections.Set` object indicating which functions in the
2057+
A :class:`~collections.abc.Set` object indicating which functions in the
20582058
:mod:`os` module permit use of their *follow_symlinks* parameter. Different
20592059
platforms provide different functionality, and an option that might work on
20602060
one might be unsupported on another. For consistency's sakes, functions that
@@ -2403,7 +2403,7 @@ Process Management
24032403

24042404
These functions may be used to create and manage processes.
24052405

2406-
The various :func:`exec\*` functions take a list of arguments for the new
2406+
The various :func:`exec\* <execl>` functions take a list of arguments for the new
24072407
program loaded into the process. In each case, the first of these arguments is
24082408
passed to the new program as its own name rather than as an argument a user may
24092409
have typed on a command line. For the C programmer, this is the ``argv[0]``
@@ -2441,9 +2441,9 @@ to be ignored.
24412441
descriptors are not flushed, so if there may be data buffered
24422442
on these open files, you should flush them using
24432443
:func:`sys.stdout.flush` or :func:`os.fsync` before calling an
2444-
:func:`exec\*` function.
2444+
:func:`exec\* <execl>` function.
24452445

2446-
The "l" and "v" variants of the :func:`exec\*` functions differ in how
2446+
The "l" and "v" variants of the :func:`exec\* <execl>` functions differ in how
24472447
command-line arguments are passed. The "l" variants are perhaps the easiest
24482448
to work with if the number of parameters is fixed when the code is written; the
24492449
individual parameters simply become additional parameters to the :func:`execl\*`
@@ -2455,7 +2455,7 @@ to be ignored.
24552455
The variants which include a "p" near the end (:func:`execlp`,
24562456
:func:`execlpe`, :func:`execvp`, and :func:`execvpe`) will use the
24572457
:envvar:`PATH` environment variable to locate the program *file*. When the
2458-
environment is being replaced (using one of the :func:`exec\*e` variants,
2458+
environment is being replaced (using one of the :func:`exec\*e <execl>` variants,
24592459
discussed in the next paragraph), the new environment is used as the source of
24602460
the :envvar:`PATH` variable. The other variants, :func:`execl`, :func:`execle`,
24612461
:func:`execv`, and :func:`execve`, will not use the :envvar:`PATH` variable to
@@ -2701,7 +2701,6 @@ written in Python, such as a mail server's external command delivery program.
27012701

27022702

27032703
.. function:: popen(...)
2704-
:noindex:
27052704

27062705
Run child processes, returning opened pipes for communications. These functions
27072706
are described in section :ref:`os-newstreams`.
@@ -2729,7 +2728,7 @@ written in Python, such as a mail server's external command delivery program.
27292728
process. On Windows, the process id will actually be the process handle, so can
27302729
be used with the :func:`waitpid` function.
27312730

2732-
The "l" and "v" variants of the :func:`spawn\*` functions differ in how
2731+
The "l" and "v" variants of the :func:`spawn\* <spawnl>` functions differ in how
27332732
command-line arguments are passed. The "l" variants are perhaps the easiest
27342733
to work with if the number of parameters is fixed when the code is written; the
27352734
individual parameters simply become additional parameters to the
@@ -2741,7 +2740,7 @@ written in Python, such as a mail server's external command delivery program.
27412740
The variants which include a second "p" near the end (:func:`spawnlp`,
27422741
:func:`spawnlpe`, :func:`spawnvp`, and :func:`spawnvpe`) will use the
27432742
:envvar:`PATH` environment variable to locate the program *file*. When the
2744-
environment is being replaced (using one of the :func:`spawn\*e` variants,
2743+
environment is being replaced (using one of the :func:`spawn\*e <spawnl>` variants,
27452744
discussed in the next paragraph), the new environment is used as the source of
27462745
the :envvar:`PATH` variable. The other variants, :func:`spawnl`,
27472746
:func:`spawnle`, :func:`spawnv`, and :func:`spawnve`, will not use the
@@ -2775,7 +2774,7 @@ written in Python, such as a mail server's external command delivery program.
27752774
.. data:: P_NOWAIT
27762775
P_NOWAITO
27772776

2778-
Possible values for the *mode* parameter to the :func:`spawn\*` family of
2777+
Possible values for the *mode* parameter to the :func:`spawn\* <spawnl>` family of
27792778
functions. If either of these values is given, the :func:`spawn\*` functions
27802779
will return as soon as the new process has been created, with the process id as
27812780
the return value.
@@ -2785,7 +2784,7 @@ written in Python, such as a mail server's external command delivery program.
27852784

27862785
.. data:: P_WAIT
27872786

2788-
Possible value for the *mode* parameter to the :func:`spawn\*` family of
2787+
Possible value for the *mode* parameter to the :func:`spawn\* <spawnl>` family of
27892788
functions. If this is given as *mode*, the :func:`spawn\*` functions will not
27902789
return until the new process has run to completion and will return the exit code
27912790
of the process the run is successful, or ``-signal`` if a signal kills the
@@ -2797,11 +2796,11 @@ written in Python, such as a mail server's external command delivery program.
27972796
.. data:: P_DETACH
27982797
P_OVERLAY
27992798

2800-
Possible values for the *mode* parameter to the :func:`spawn\*` family of
2799+
Possible values for the *mode* parameter to the :func:`spawn\* <spawnl>` family of
28012800
functions. These are less portable than those listed above. :const:`P_DETACH`
28022801
is similar to :const:`P_NOWAIT`, but the new process is detached from the
28032802
console of the calling process. If :const:`P_OVERLAY` is used, the current
2804-
process will be replaced; the :func:`spawn\*` function will not return.
2803+
process will be replaced; the :func:`spawn\* <spawnl>` function will not return.
28052804

28062805
Availability: Windows.
28072806

@@ -2973,17 +2972,18 @@ written in Python, such as a mail server's external command delivery program.
29732972
(shifting makes cross-platform use of the function easier). A *pid* less than or
29742973
equal to ``0`` has no special meaning on Windows, and raises an exception. The
29752974
value of integer *options* has no effect. *pid* can refer to any process whose
2976-
id is known, not necessarily a child process. The :func:`spawn` functions called
2977-
with :const:`P_NOWAIT` return suitable process handles.
2975+
id is known, not necessarily a child process. The :func:`spawn\* <spawnl>`
2976+
functions called with :const:`P_NOWAIT` return suitable process handles.
29782977

29792978

29802979
.. function:: wait3(options)
29812980

29822981
Similar to :func:`waitpid`, except no process id argument is given and a
29832982
3-element tuple containing the child's process id, exit status indication, and
29842983
resource usage information is returned. Refer to :mod:`resource`.\
2985-
:func:`getrusage` for details on resource usage information. The option
2986-
argument is the same as that provided to :func:`waitpid` and :func:`wait4`.
2984+
:func:`~resource.getrusage` for details on resource usage information. The
2985+
option argument is the same as that provided to :func:`waitpid` and
2986+
:func:`wait4`.
29872987

29882988
Availability: Unix.
29892989

@@ -2992,9 +2992,9 @@ written in Python, such as a mail server's external command delivery program.
29922992

29932993
Similar to :func:`waitpid`, except a 3-element tuple, containing the child's
29942994
process id, exit status indication, and resource usage information is returned.
2995-
Refer to :mod:`resource`.\ :func:`getrusage` for details on resource usage
2996-
information. The arguments to :func:`wait4` are the same as those provided to
2997-
:func:`waitpid`.
2995+
Refer to :mod:`resource`.\ :func:`~resource.getrusage` for details on
2996+
resource usage information. The arguments to :func:`wait4` are the same
2997+
as those provided to :func:`waitpid`.
29982998

29992999
Availability: Unix.
30003000

@@ -3330,8 +3330,9 @@ Higher-level operations on pathnames are defined in the :mod:`os.path` module.
33303330

33313331
.. data:: defpath
33323332

3333-
The default search path used by :func:`exec\*p\*` and :func:`spawn\*p\*` if the
3334-
environment doesn't have a ``'PATH'`` key. Also available via :mod:`os.path`.
3333+
The default search path used by :func:`exec\*p\* <execl>` and
3334+
:func:`spawn\*p\* <spawnl>` if the environment doesn't have a ``'PATH'``
3335+
key. Also available via :mod:`os.path`.
33353336

33363337

33373338
.. data:: linesep

Doc/library/posix.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ systems the :mod:`posix` module is not available, but a subset is always
1919
available through the :mod:`os` interface. Once :mod:`os` is imported, there is
2020
*no* performance penalty in using it instead of :mod:`posix`. In addition,
2121
:mod:`os` provides some additional functionality, such as automatically calling
22-
:func:`putenv` when an entry in ``os.environ`` is changed.
22+
:func:`~os.putenv` when an entry in ``os.environ`` is changed.
2323

2424
Errors are reported as exceptions; the usual exceptions are given for type
2525
errors, while errors reported by the system calls raise :exc:`OSError`.
@@ -74,9 +74,10 @@ In addition to many functions described in the :mod:`os` module documentation,
7474
pathname of your home directory, equivalent to ``getenv("HOME")`` in C.
7575

7676
Modifying this dictionary does not affect the string environment passed on by
77-
:func:`execv`, :func:`popen` or :func:`system`; if you need to change the
78-
environment, pass ``environ`` to :func:`execve` or add variable assignments and
79-
export statements to the command string for :func:`system` or :func:`popen`.
77+
:func:`~os.execv`, :func:`~os.popen` or :func:`~os.system`; if you need to
78+
change the environment, pass ``environ`` to :func:`~os.execve` or add
79+
variable assignments and export statements to the command string for
80+
:func:`~os.system` or :func:`~os.popen`.
8081

8182
.. versionchanged:: 3.2
8283
On Unix, keys and values are bytes.

0 commit comments

Comments
 (0)