Skip to content

Commit f428c4d

Browse files
authored
gh-101100: Fix Sphinx warnings in library/tarfile.rst (#113237)
Fix Sphinx warnings in library/tarfile.rst
1 parent 2b93f52 commit f428c4d

File tree

2 files changed

+56
-12
lines changed

2 files changed

+56
-12
lines changed

Doc/library/tarfile.rst

+56-11
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Some facts and figures:
116116
``'filemode|[compression]'``. :func:`tarfile.open` will return a :class:`TarFile`
117117
object that processes its data as a stream of blocks. No random seeking will
118118
be done on the file. If given, *fileobj* may be any object that has a
119-
:meth:`read` or :meth:`write` method (depending on the *mode*). *bufsize*
119+
:meth:`~io.TextIOBase.read` or :meth:`~io.TextIOBase.write` method (depending on the *mode*). *bufsize*
120120
specifies the blocksize and defaults to ``20 * 512`` bytes. Use this variant
121121
in combination with e.g. ``sys.stdin``, a socket :term:`file object` or a tape
122122
device. However, such a :class:`TarFile` object is limited in that it does
@@ -255,6 +255,51 @@ The following constants are available at the module level:
255255
The default character encoding: ``'utf-8'`` on Windows, the value returned by
256256
:func:`sys.getfilesystemencoding` otherwise.
257257

258+
.. data:: REGTYPE
259+
AREGTYPE
260+
261+
A regular file :attr:`~TarInfo.type`.
262+
263+
.. data:: LNKTYPE
264+
265+
A link (inside tarfile) :attr:`~TarInfo.type`.
266+
267+
.. data:: SYMTYPE
268+
269+
A symbolic link :attr:`~TarInfo.type`.
270+
271+
.. data:: CHRTYPE
272+
273+
A character special device :attr:`~TarInfo.type`.
274+
275+
.. data:: BLKTYPE
276+
277+
A block special device :attr:`~TarInfo.type`.
278+
279+
.. data:: DIRTYPE
280+
281+
A directory :attr:`~TarInfo.type`.
282+
283+
.. data:: FIFOTYPE
284+
285+
A FIFO special device :attr:`~TarInfo.type`.
286+
287+
.. data:: CONTTYPE
288+
289+
A contiguous file :attr:`~TarInfo.type`.
290+
291+
.. data:: GNUTYPE_LONGNAME
292+
293+
A GNU tar longname :attr:`~TarInfo.type`.
294+
295+
.. data:: GNUTYPE_LONGLINK
296+
297+
A GNU tar longlink :attr:`~TarInfo.type`.
298+
299+
.. data:: GNUTYPE_SPARSE
300+
301+
A GNU tar sparse file :attr:`~TarInfo.type`.
302+
258303

259304
Each of the following constants defines a tar archive format that the
260305
:mod:`tarfile` module is able to create. See section :ref:`tar-formats` for
@@ -325,7 +370,7 @@ be finalized; only the internally used file object will be closed. See the
325370

326371
*name* is the pathname of the archive. *name* may be a :term:`path-like object`.
327372
It can be omitted if *fileobj* is given.
328-
In this case, the file object's :attr:`name` attribute is used if it exists.
373+
In this case, the file object's :attr:`!name` attribute is used if it exists.
329374

330375
*mode* is either ``'r'`` to read from an existing archive, ``'a'`` to append
331376
data to an existing file, ``'w'`` to create a new file overwriting an existing
@@ -359,7 +404,7 @@ be finalized; only the internally used file object will be closed. See the
359404
messages). The messages are written to ``sys.stderr``.
360405

361406
*errorlevel* controls how extraction errors are handled,
362-
see :attr:`the corresponding attribute <~TarFile.errorlevel>`.
407+
see :attr:`the corresponding attribute <TarFile.errorlevel>`.
363408

364409
The *encoding* and *errors* arguments define the character encoding to be
365410
used for reading or writing the archive and how conversion errors are going
@@ -645,8 +690,8 @@ It does *not* contain the file's data itself.
645690
:meth:`~TarFile.getmember`, :meth:`~TarFile.getmembers` and
646691
:meth:`~TarFile.gettarinfo`.
647692

648-
Modifying the objects returned by :meth:`~!TarFile.getmember` or
649-
:meth:`~!TarFile.getmembers` will affect all subsequent
693+
Modifying the objects returned by :meth:`~TarFile.getmember` or
694+
:meth:`~TarFile.getmembers` will affect all subsequent
650695
operations on the archive.
651696
For cases where this is unwanted, you can use :mod:`copy.copy() <copy>` or
652697
call the :meth:`~TarInfo.replace` method to create a modified copy in one step.
@@ -795,8 +840,8 @@ A ``TarInfo`` object has the following public data attributes:
795840

796841
A dictionary containing key-value pairs of an associated pax extended header.
797842

798-
.. method:: TarInfo.replace(name=..., mtime=..., mode=..., linkname=...,
799-
uid=..., gid=..., uname=..., gname=...,
843+
.. method:: TarInfo.replace(name=..., mtime=..., mode=..., linkname=..., \
844+
uid=..., gid=..., uname=..., gname=..., \
800845
deep=True)
801846

802847
.. versionadded:: 3.12
@@ -816,7 +861,7 @@ A :class:`TarInfo` object also provides some convenient query methods:
816861

817862
.. method:: TarInfo.isfile()
818863

819-
Return :const:`True` if the :class:`Tarinfo` object is a regular file.
864+
Return :const:`True` if the :class:`TarInfo` object is a regular file.
820865

821866

822867
.. method:: TarInfo.isreg()
@@ -952,7 +997,7 @@ reused in custom filters:
952997
path (after following symlinks) would end up outside the destination.
953998
This raises :class:`~tarfile.OutsideDestinationError`.
954999
- Clear high mode bits (setuid, setgid, sticky) and group/other write bits
955-
(:const:`~stat.S_IWGRP`|:const:`~stat.S_IWOTH`).
1000+
(:const:`~stat.S_IWGRP` | :const:`~stat.S_IWOTH`).
9561001

9571002
Return the modified ``TarInfo`` member.
9581003

@@ -977,9 +1022,9 @@ reused in custom filters:
9771022
- For regular files, including hard links:
9781023

9791024
- Set the owner read and write permissions
980-
(:const:`~stat.S_IRUSR`|:const:`~stat.S_IWUSR`).
1025+
(:const:`~stat.S_IRUSR` | :const:`~stat.S_IWUSR`).
9811026
- Remove the group & other executable permission
982-
(:const:`~stat.S_IXGRP`|:const:`~stat.S_IXOTH`)
1027+
(:const:`~stat.S_IXGRP` | :const:`~stat.S_IXOTH`)
9831028
if the owner doesn’t have it (:const:`~stat.S_IXUSR`).
9841029

9851030
- For other files (directories), set ``mode`` to ``None``, so

Doc/tools/.nitignore

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ Doc/library/ssl.rst
8686
Doc/library/stdtypes.rst
8787
Doc/library/string.rst
8888
Doc/library/subprocess.rst
89-
Doc/library/tarfile.rst
9089
Doc/library/termios.rst
9190
Doc/library/test.rst
9291
Doc/library/tkinter.rst

0 commit comments

Comments
 (0)