Python Glossary Русский

Python 3.3+lzmafunction

lzma.is_check_supported()

integrity checks

Reports whether the installed liblzma supports a given checksum type — CRC32, CRC64 or SHA-256.

Syntax

ok = lzma.is_check_supported(check)

CHECK_NONE and CHECK_CRC32 are always supported, while CRC64 and SHA-256 can be disabled when liblzma is built — then compressing with that check fails with LZMAError. Use the function to choose a checksum up front instead of catching the error. An unknown check number gives False, not an exception.

Examples

import lzma
print(lzma.is_check_supported(lzma.CHECK_CRC32))  # → True
print(lzma.is_check_supported(lzma.CHECK_ID_MAX))  # → False
check = lzma.CHECK_SHA256 if lzma.is_check_supported(lzma.CHECK_SHA256) else lzma.CHECK_CRC32
print(lzma.decompress(lzma.compress(b'x', check=check)))  # → b'x'

See also

Open in the full glossarydocs.python.orgReport an inaccuracy