Skip to content

Commit 76537eb

Browse files
authored
BZ2Compressor and BZ2Decompressor live in the _bz2 module (#12976)
1 parent 65af6e4 commit 76537eb

File tree

7 files changed

+25
-21
lines changed

7 files changed

+25
-21
lines changed

stdlib/@tests/stubtest_allowlists/py310.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ _weakref.ProxyType.__reversed__ # Doesn't really exist
33
asyncio.base_events.BaseEventLoop.subprocess_exec # BaseEventLoop adds several parameters and stubtest fails on the difference if we add them
44
builtins.float.__setformat__ # Internal method for CPython test suite
55
builtins.property.__set_name__ # Doesn't actually exist
6-
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
6+
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
77
collections\.UserList\.index # ignoring pos-or-keyword parameter
88
configparser.ParsingError.filename
99
contextlib.AbstractAsyncContextManager.__class_getitem__

stdlib/@tests/stubtest_allowlists/py311.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ _collections_abc.Iterable.__class_getitem__
55
_collections_abc.MappingView.__class_getitem__
66
_csv.Reader
77
_csv.Writer
8-
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
8+
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
99
configparser.ParsingError.filename
1010
collections\.UserList\.index # ignoring pos-or-keyword parameter
1111
enum.Enum.__init__

stdlib/@tests/stubtest_allowlists/py38.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ asyncio.transports.WriteTransport.get_write_buffer_limits # Documented. Exists
1414
asyncio.WriteTransport.get_write_buffer_limits # Documented. Exists in subclasses, but not in WriteTransport itself
1515
builtins.float.__set_format__ # Internal method for CPython test suite
1616
builtins.input # Incorrect default value in text signature, fixed in 3.10
17-
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
17+
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
1818
collections.AsyncGenerator.asend # async at runtime, deliberately not in the stub, see #7491. Pos-only differences also.
1919
collections.AsyncGenerator.__anext__ # async at runtime, deliberately not in the stub, see #7491
2020
collections.AsyncGenerator.aclose # async at runtime, deliberately not in the stub, see #7491

stdlib/@tests/stubtest_allowlists/py39.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ast.ExtSlice.__new__
33
ast.Index.__new__
44
builtins.float.__setformat__ # Internal method for CPython test suite
55
builtins.input # Incorrect default value in text signature, fixed in 3.10
6-
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
6+
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
77
collections.AsyncGenerator.asend # async at runtime, deliberately not in the stub, see #7491. Pos-only differences also.
88
collections.AsyncGenerator.__anext__ # async at runtime, deliberately not in the stub, see #7491
99
collections.AsyncGenerator.aclose # async at runtime, deliberately not in the stub, see #7491

stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ _asyncio: 3.0-
2424
_bisect: 3.0-
2525
_blake2: 3.6-
2626
_bootlocale: 3.4-3.9
27+
_bz2: 3.3-
2728
_codecs: 3.0-
2829
_collections_abc: 3.3-
2930
_compat_pickle: 3.1-

stdlib/_bz2.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from _typeshed import ReadableBuffer
2+
from typing import final
3+
4+
@final
5+
class BZ2Compressor:
6+
def __init__(self, compresslevel: int = 9) -> None: ...
7+
def compress(self, data: ReadableBuffer, /) -> bytes: ...
8+
def flush(self) -> bytes: ...
9+
10+
@final
11+
class BZ2Decompressor:
12+
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
13+
@property
14+
def eof(self) -> bool: ...
15+
@property
16+
def needs_input(self) -> bool: ...
17+
@property
18+
def unused_data(self) -> bytes: ...

stdlib/bz2.pyi

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import _compression
22
import sys
3+
from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompressor
34
from _compression import BaseStream
45
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
56
from collections.abc import Iterable
6-
from typing import IO, Any, Literal, Protocol, SupportsIndex, TextIO, final, overload
7+
from typing import IO, Any, Literal, Protocol, SupportsIndex, TextIO, overload
78
from typing_extensions import Self, TypeAlias
89

910
__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"]
@@ -128,19 +129,3 @@ class BZ2File(BaseStream, IO[bytes]):
128129
def seek(self, offset: int, whence: int = 0) -> int: ...
129130
def write(self, data: ReadableBuffer) -> int: ...
130131
def writelines(self, seq: Iterable[ReadableBuffer]) -> None: ...
131-
132-
@final
133-
class BZ2Compressor:
134-
def __init__(self, compresslevel: int = 9) -> None: ...
135-
def compress(self, data: ReadableBuffer, /) -> bytes: ...
136-
def flush(self) -> bytes: ...
137-
138-
@final
139-
class BZ2Decompressor:
140-
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
141-
@property
142-
def eof(self) -> bool: ...
143-
@property
144-
def needs_input(self) -> bool: ...
145-
@property
146-
def unused_data(self) -> bytes: ...

0 commit comments

Comments
 (0)