Skip to content

Commit 41d7b3c

Browse files
miss-islingtonfedonmanhugovk
authored
[3.15] gh-151949: Fix Sphinx reference warnings in Doc/library/lzma.rst (GH-153878) (#154127)
* gh-151949: Fix Sphinx reference warnings in `Doc/library/lzma.rst` (GH-153878) The lzma module constants (FORMAT_*, CHECK_*, PRESET_*, FILTER_*, MODE_* and MF_*) were referenced with the :const: role throughout the module documentation but were never defined as reference targets, producing "reference target not found" warnings under nitpicky mode. Document these public constants with .. data:: directives, following the convention used by the signal, socket and ssl modules, so the existing references resolve. The now-redundant inline descriptions of the format and check constants are condensed into linked references. (cherry picked from commit 1530b38) Co-authored-by: Vyron Vasileiadis <hi@fedonman.com> * Fix nitpicks --------- Co-authored-by: Vyron Vasileiadis <hi@fedonman.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent a47c03d commit 41d7b3c

2 files changed

Lines changed: 111 additions & 33 deletions

File tree

Doc/library/lzma.rst

Lines changed: 111 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -152,35 +152,14 @@ Compressing and decompressing data in memory
152152
:func:`compress`.
153153

154154
The *format* argument specifies what container format should be used.
155-
Possible values are:
156-
157-
* :const:`FORMAT_XZ`: The ``.xz`` container format.
158-
This is the default format.
159-
160-
* :const:`FORMAT_ALONE`: The legacy ``.lzma`` container format.
161-
This format is more limited than ``.xz`` -- it does not support integrity
162-
checks or multiple filters.
163-
164-
* :const:`FORMAT_RAW`: A raw data stream, not using any container format.
165-
This format specifier does not support integrity checks, and requires that
166-
you always specify a custom filter chain (for both compression and
167-
decompression). Additionally, data compressed in this manner cannot be
168-
decompressed using :const:`FORMAT_AUTO` (see :class:`LZMADecompressor`).
155+
Possible values are :const:`FORMAT_XZ` (the default),
156+
:const:`FORMAT_ALONE` and :const:`FORMAT_RAW`.
169157

170158
The *check* argument specifies the type of integrity check to include in the
171159
compressed data. This check is used when decompressing, to ensure that the
172-
data has not been corrupted. Possible values are:
173-
174-
* :const:`CHECK_NONE`: No integrity check.
175-
This is the default (and the only acceptable value) for
176-
:const:`FORMAT_ALONE` and :const:`FORMAT_RAW`.
177-
178-
* :const:`CHECK_CRC32`: 32-bit Cyclic Redundancy Check.
179-
180-
* :const:`CHECK_CRC64`: 64-bit Cyclic Redundancy Check.
181-
This is the default for :const:`FORMAT_XZ`.
182-
183-
* :const:`CHECK_SHA256`: 256-bit Secure Hash Algorithm.
160+
data has not been corrupted. Possible values are :const:`CHECK_NONE`,
161+
:const:`CHECK_CRC32`, :const:`CHECK_CRC64` (the default for
162+
:const:`FORMAT_XZ`) and :const:`CHECK_SHA256`.
184163

185164
If the specified check is not supported, an :class:`LZMAError` is raised.
186165

@@ -356,12 +335,12 @@ options. Valid filter IDs are as follows:
356335

357336
* Branch-Call-Jump (BCJ) filters:
358337

359-
* :const:`FILTER_X86`
360-
* :const:`FILTER_IA64`
361-
* :const:`FILTER_ARM`
362-
* :const:`FILTER_ARMTHUMB`
363-
* :const:`FILTER_POWERPC`
364-
* :const:`FILTER_SPARC`
338+
* :const:`!FILTER_X86`
339+
* :const:`!FILTER_IA64`
340+
* :const:`!FILTER_ARM`
341+
* :const:`!FILTER_ARMTHUMB`
342+
* :const:`!FILTER_POWERPC`
343+
* :const:`!FILTER_SPARC`
365344

366345
A filter chain can consist of up to 4 filters, and cannot be empty. The last
367346
filter in the chain must be a compression filter, and any other filters must be
@@ -398,6 +377,106 @@ These filters support one option, ``start_offset``. This specifies the address
398377
that should be mapped to the beginning of the input data. The default is 0.
399378

400379

380+
Constants
381+
---------
382+
383+
The following module-level constants are provided for use as the *format*,
384+
*check*, *preset* and *filters* arguments of the classes and functions above.
385+
386+
Container formats:
387+
388+
.. data:: FORMAT_XZ
389+
390+
The ``.xz`` container format.
391+
392+
.. data:: FORMAT_ALONE
393+
394+
The legacy ``.lzma`` container format. This format is more limited than
395+
``.xz`` -- it does not support integrity checks or multiple filters.
396+
397+
.. data:: FORMAT_RAW
398+
399+
A raw data stream, not using any container format. This format specifier
400+
does not support integrity checks, and requires that you always specify a
401+
custom filter chain (for both compression and decompression). Additionally,
402+
data compressed in this manner cannot be decompressed using
403+
:const:`FORMAT_AUTO`.
404+
405+
.. data:: FORMAT_AUTO
406+
407+
Used for decompression only. The container format is detected
408+
automatically, so that both ``.xz`` and ``.lzma`` files can be decompressed.
409+
410+
Integrity checks:
411+
412+
.. data:: CHECK_NONE
413+
414+
No integrity check. This is the default (and the only acceptable value) for
415+
:const:`FORMAT_ALONE` and :const:`FORMAT_RAW`.
416+
417+
.. data:: CHECK_CRC32
418+
419+
A 32-bit Cyclic Redundancy Check.
420+
421+
.. data:: CHECK_CRC64
422+
423+
A 64-bit Cyclic Redundancy Check. This is the default for
424+
:const:`FORMAT_XZ`.
425+
426+
.. data:: CHECK_SHA256
427+
428+
A 256-bit Secure Hash Algorithm.
429+
430+
.. data:: CHECK_UNKNOWN
431+
432+
The integrity check used by a stream could not yet be determined. This may
433+
be the value of the :attr:`LZMADecompressor.check` attribute until enough of
434+
the input has been decoded.
435+
436+
.. data:: CHECK_ID_MAX
437+
438+
The largest supported integrity-check ID.
439+
440+
Compression presets:
441+
442+
.. data:: PRESET_DEFAULT
443+
444+
The default compression preset, equivalent to preset level ``6``.
445+
446+
.. data:: PRESET_EXTREME
447+
448+
A flag that may be bitwise OR-ed with a preset level (``0`` to ``9``) to
449+
select a slower but more thorough variant of that preset.
450+
451+
Filter IDs and options:
452+
453+
.. data:: FILTER_LZMA1
454+
FILTER_LZMA2
455+
456+
The LZMA1 and LZMA2 compression filters. :const:`FILTER_LZMA1` is for use
457+
with :const:`FORMAT_ALONE`, while :const:`FILTER_LZMA2` is for use with
458+
:const:`FORMAT_XZ` and :const:`FORMAT_RAW`.
459+
460+
.. data:: FILTER_DELTA
461+
462+
The delta filter.
463+
464+
.. data:: MODE_FAST
465+
MODE_NORMAL
466+
467+
Compression modes that may be used as the ``mode`` option of a filter
468+
specifier (see :ref:`filter-chain-specs`).
469+
470+
.. data:: MF_HC3
471+
MF_HC4
472+
MF_BT2
473+
MF_BT3
474+
MF_BT4
475+
476+
Match finders that may be used as the ``mf`` option of a filter specifier
477+
(see :ref:`filter-chain-specs`).
478+
479+
401480
Examples
402481
--------
403482

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Doc/library/email.parser.rst
1212
Doc/library/importlib.rst
1313
Doc/library/logging.config.rst
1414
Doc/library/logging.handlers.rst
15-
Doc/library/lzma.rst
1615
Doc/library/mmap.rst
1716
Doc/library/multiprocessing.rst
1817
Doc/library/optparse.rst

0 commit comments

Comments
 (0)