Skip to content

Commit 65af6e4

Browse files
authored
LZMADecompressor, LZMACompressor, and LZMAError live in _lzma (#12977)
1 parent 460c09d commit 65af6e4

3 files changed

Lines changed: 97 additions & 59 deletions

File tree

stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ _io: 3.0-
4848
_json: 3.0-
4949
_locale: 3.0-
5050
_lsprof: 3.0-
51+
_lzma: 3.3-
5152
_markupbase: 3.0-
5253
_msi: 3.0-3.12
5354
_operator: 3.4-

stdlib/_lzma.pyi

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from _typeshed import ReadableBuffer
2+
from collections.abc import Mapping, Sequence
3+
from typing import Any, Final, final
4+
from typing_extensions import TypeAlias
5+
6+
_FilterChain: TypeAlias = Sequence[Mapping[str, Any]]
7+
8+
FORMAT_AUTO: Final = 0
9+
FORMAT_XZ: Final = 1
10+
FORMAT_ALONE: Final = 2
11+
FORMAT_RAW: Final = 3
12+
CHECK_NONE: Final = 0
13+
CHECK_CRC32: Final = 1
14+
CHECK_CRC64: Final = 4
15+
CHECK_SHA256: Final = 10
16+
CHECK_ID_MAX: Final = 15
17+
CHECK_UNKNOWN: Final = 16
18+
FILTER_LZMA1: int # v big number
19+
FILTER_LZMA2: Final = 33
20+
FILTER_DELTA: Final = 3
21+
FILTER_X86: Final = 4
22+
FILTER_IA64: Final = 6
23+
FILTER_ARM: Final = 7
24+
FILTER_ARMTHUMB: Final = 8
25+
FILTER_SPARC: Final = 9
26+
FILTER_POWERPC: Final = 5
27+
MF_HC3: Final = 3
28+
MF_HC4: Final = 4
29+
MF_BT2: Final = 18
30+
MF_BT3: Final = 19
31+
MF_BT4: Final = 20
32+
MODE_FAST: Final = 1
33+
MODE_NORMAL: Final = 2
34+
PRESET_DEFAULT: Final = 6
35+
PRESET_EXTREME: int # v big number
36+
37+
@final
38+
class LZMADecompressor:
39+
def __init__(self, format: int | None = ..., memlimit: int | None = ..., filters: _FilterChain | None = ...) -> None: ...
40+
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
41+
@property
42+
def check(self) -> int: ...
43+
@property
44+
def eof(self) -> bool: ...
45+
@property
46+
def unused_data(self) -> bytes: ...
47+
@property
48+
def needs_input(self) -> bool: ...
49+
50+
@final
51+
class LZMACompressor:
52+
def __init__(
53+
self, format: int | None = ..., check: int = ..., preset: int | None = ..., filters: _FilterChain | None = ...
54+
) -> None: ...
55+
def compress(self, data: ReadableBuffer, /) -> bytes: ...
56+
def flush(self) -> bytes: ...
57+
58+
class LZMAError(Exception): ...
59+
60+
def is_check_supported(check_id: int, /) -> bool: ...

stdlib/lzma.pyi

Lines changed: 36 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
11
from _compression import BaseStream
2+
from _lzma import (
3+
CHECK_CRC32 as CHECK_CRC32,
4+
CHECK_CRC64 as CHECK_CRC64,
5+
CHECK_ID_MAX as CHECK_ID_MAX,
6+
CHECK_NONE as CHECK_NONE,
7+
CHECK_SHA256 as CHECK_SHA256,
8+
CHECK_UNKNOWN as CHECK_UNKNOWN,
9+
FILTER_ARM as FILTER_ARM,
10+
FILTER_ARMTHUMB as FILTER_ARMTHUMB,
11+
FILTER_DELTA as FILTER_DELTA,
12+
FILTER_IA64 as FILTER_IA64,
13+
FILTER_LZMA1 as FILTER_LZMA1,
14+
FILTER_LZMA2 as FILTER_LZMA2,
15+
FILTER_POWERPC as FILTER_POWERPC,
16+
FILTER_SPARC as FILTER_SPARC,
17+
FILTER_X86 as FILTER_X86,
18+
FORMAT_ALONE as FORMAT_ALONE,
19+
FORMAT_AUTO as FORMAT_AUTO,
20+
FORMAT_RAW as FORMAT_RAW,
21+
FORMAT_XZ as FORMAT_XZ,
22+
MF_BT2 as MF_BT2,
23+
MF_BT3 as MF_BT3,
24+
MF_BT4 as MF_BT4,
25+
MF_HC3 as MF_HC3,
26+
MF_HC4 as MF_HC4,
27+
MODE_FAST as MODE_FAST,
28+
MODE_NORMAL as MODE_NORMAL,
29+
PRESET_DEFAULT as PRESET_DEFAULT,
30+
PRESET_EXTREME as PRESET_EXTREME,
31+
LZMACompressor as LZMACompressor,
32+
LZMADecompressor as LZMADecompressor,
33+
LZMAError as LZMAError,
34+
_FilterChain,
35+
is_check_supported as is_check_supported,
36+
)
237
from _typeshed import ReadableBuffer, StrOrBytesPath
3-
from collections.abc import Mapping, Sequence
4-
from typing import IO, Any, Final, Literal, TextIO, final, overload
38+
from typing import IO, Literal, TextIO, overload
539
from typing_extensions import Self, TypeAlias
640

741
__all__ = [
@@ -48,62 +82,6 @@ _OpenTextWritingMode: TypeAlias = Literal["wt", "xt", "at"]
4882

4983
_PathOrFile: TypeAlias = StrOrBytesPath | IO[bytes]
5084

51-
_FilterChain: TypeAlias = Sequence[Mapping[str, Any]]
52-
53-
FORMAT_AUTO: Final = 0
54-
FORMAT_XZ: Final = 1
55-
FORMAT_ALONE: Final = 2
56-
FORMAT_RAW: Final = 3
57-
CHECK_NONE: Final = 0
58-
CHECK_CRC32: Final = 1
59-
CHECK_CRC64: Final = 4
60-
CHECK_SHA256: Final = 10
61-
CHECK_ID_MAX: Final = 15
62-
CHECK_UNKNOWN: Final = 16
63-
FILTER_LZMA1: int # v big number
64-
FILTER_LZMA2: Final = 33
65-
FILTER_DELTA: Final = 3
66-
FILTER_X86: Final = 4
67-
FILTER_IA64: Final = 6
68-
FILTER_ARM: Final = 7
69-
FILTER_ARMTHUMB: Final = 8
70-
FILTER_SPARC: Final = 9
71-
FILTER_POWERPC: Final = 5
72-
MF_HC3: Final = 3
73-
MF_HC4: Final = 4
74-
MF_BT2: Final = 18
75-
MF_BT3: Final = 19
76-
MF_BT4: Final = 20
77-
MODE_FAST: Final = 1
78-
MODE_NORMAL: Final = 2
79-
PRESET_DEFAULT: Final = 6
80-
PRESET_EXTREME: int # v big number
81-
82-
# from _lzma.c
83-
@final
84-
class LZMADecompressor:
85-
def __init__(self, format: int | None = ..., memlimit: int | None = ..., filters: _FilterChain | None = ...) -> None: ...
86-
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
87-
@property
88-
def check(self) -> int: ...
89-
@property
90-
def eof(self) -> bool: ...
91-
@property
92-
def unused_data(self) -> bytes: ...
93-
@property
94-
def needs_input(self) -> bool: ...
95-
96-
# from _lzma.c
97-
@final
98-
class LZMACompressor:
99-
def __init__(
100-
self, format: int | None = ..., check: int = ..., preset: int | None = ..., filters: _FilterChain | None = ...
101-
) -> None: ...
102-
def compress(self, data: ReadableBuffer, /) -> bytes: ...
103-
def flush(self) -> bytes: ...
104-
105-
class LZMAError(Exception): ...
106-
10785
class LZMAFile(BaseStream, IO[bytes]): # type: ignore[misc] # incompatible definitions of writelines in the base classes
10886
def __init__(
10987
self,
@@ -194,4 +172,3 @@ def compress(
194172
def decompress(
195173
data: ReadableBuffer, format: int = 0, memlimit: int | None = None, filters: _FilterChain | None = None
196174
) -> bytes: ...
197-
def is_check_supported(check_id: int, /) -> bool: ...

0 commit comments

Comments
 (0)