11from __future__ import annotations
22
33import io
4- from _compression import DecompressReader as DecompressReader_other , _Reader as _Reader_other
4+ import sys
55from _typeshed import ReadableBuffer
66from bz2 import BZ2Decompressor
7- from compression ._common ._streams import DecompressReader , _Decompressor , _Reader
87from compression .zstd import ZstdDecompressor
98from lzma import LZMADecompressor
109from typing import cast
1110from typing_extensions import assert_type
1211from zlib import decompressobj
1312
13+ if sys .version_info >= (3 , 14 ):
14+ from compression ._common ._streams import DecompressReader , _Decompressor , _Reader
15+ else :
16+ from _compression import DecompressReader , _Reader
17+
1418###
1519# Tests for DecompressReader/_Decompressor
1620###
@@ -39,7 +43,6 @@ def accept_decompressor(d: _Decompressor) -> None:
3943 assert_type (d .unused_data , bytes )
4044
4145
42- # Test objects from compression._common._streams
4346fp = cast (_Reader , io .BytesIO (b"hello world" ))
4447DecompressReader (fp , decompressobj )
4548DecompressReader (fp , BZ2Decompressor )
@@ -51,11 +54,3 @@ def accept_decompressor(d: _Decompressor) -> None:
5154accept_decompressor (LZMADecompressor ())
5255accept_decompressor (ZstdDecompressor ())
5356accept_decompressor (CustomDecompressor ())
54-
55- # Test objects from _compression
56- fp = cast (_Reader_other , io .BytesIO (b"hello world" ))
57- DecompressReader_other (fp , decompressobj )
58- DecompressReader_other (fp , BZ2Decompressor )
59- DecompressReader_other (fp , LZMADecompressor )
60- DecompressReader_other (fp , ZstdDecompressor )
61- DecompressReader_other (fp , CustomDecompressor )
0 commit comments