Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more diff-friendly disabling xz
  • Loading branch information
youknowone committed May 7, 2025
commit acae154f1b1f4ad95a477ddf26d7644dc45aefa7
13 changes: 9 additions & 4 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,13 @@ def __init__(self, name, mode, comptype, fileobj, bufsize,

elif comptype == "xz":
try:
# TODO: RUSTPYTHON remove underscore
import lzma_
import lzma
except ImportError:
raise CompressionError("lzma module is not available") from None

# XXX: RUSTPYTHON; xz is not supported yet
raise CompressionError("lzma module is not available") from None

if mode == "r":
self.dbuf = b""
self.cmp = lzma.LZMADecompressor()
Expand Down Expand Up @@ -1924,11 +1927,13 @@ def xzopen(cls, name, mode="r", fileobj=None, preset=None, **kwargs):
raise ValueError("mode must be 'r', 'w' or 'x'")

try:
# TODO: RUSTPYTHON remove underscore
from lzma_ import LZMAFile, LZMAError
from lzma import LZMAFile, LZMAError
except ImportError:
raise CompressionError("lzma module is not available") from None

# XXX: RUSTPYTHON; xz is not supported yet
raise CompressionError("lzma module is not available") from None

fileobj = LZMAFile(fileobj or name, mode, preset=preset)

try:
Expand Down
10 changes: 5 additions & 5 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ def requires_bz2(reason='requires bz2'):
return unittest.skipUnless(bz2, reason)

def requires_lzma(reason='requires lzma'):
# try:
# import lzma
# except ImportError:
# lzma = None
# TODO: RUSTPYTHON
try:
import lzma
except ImportError:
lzma = None
# XXX: RUSTPYTHON; xz is not supported yet
lzma = None
return unittest.skipUnless(lzma, reason)

Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
except ImportError:
bz2 = None
try:
# TODO: RUSTPYTHON
lzma = None
# import lzma
import lzma
except ImportError:
lzma = None
# XXX: RUSTPYTHON; xz is not supported yet
lzma = None

def sha256sum(data):
return sha256(data).hexdigest()
Expand Down
Loading