https://github.com/python/cpython/commit/50b53706646cc130dcc71496f4a5bee14e9a1d9a
commit: 50b53706646cc130dcc71496f4a5bee14e9a1d9a
branch: main
author: Rogdham <3994389+rogd...@users.noreply.github.com>
committer: AA-Turner <9087854+aa-tur...@users.noreply.github.com>
date: 2025-05-10T03:32:22+01:00
summary:

gh-132983: Don't allow trailer data in ZstdFile (#133736)

files:
M Lib/compression/zstd/_zstdfile.py
M Lib/test/test_zstd.py

diff --git a/Lib/compression/zstd/_zstdfile.py 
b/Lib/compression/zstd/_zstdfile.py
index 1ff249965692ae..0086c13d3c1419 100644
--- a/Lib/compression/zstd/_zstdfile.py
+++ b/Lib/compression/zstd/_zstdfile.py
@@ -89,7 +89,6 @@ def __init__(self, file, /, mode="r", *,
             raw = _streams.DecompressReader(
                 self._fp,
                 ZstdDecompressor,
-                trailing_error=ZstdError,
                 zstd_dict=zstd_dict,
                 options=options,
             )
diff --git a/Lib/test/test_zstd.py b/Lib/test/test_zstd.py
index ff2ead68fa89f5..713294c4c27685 100644
--- a/Lib/test/test_zstd.py
+++ b/Lib/test/test_zstd.py
@@ -1682,10 +1682,10 @@ def test_read_incomplete(self):
 
         # Trailing data isn't a valid compressed stream
         with ZstdFile(io.BytesIO(self.FRAME_42 + b'12345')) as f:
-            self.assertEqual(f.read(), self.DECOMPRESSED_42)
+            self.assertRaises(ZstdError, f.read)
 
         with ZstdFile(io.BytesIO(SKIPPABLE_FRAME + b'12345')) as f:
-            self.assertEqual(f.read(), b'')
+            self.assertRaises(ZstdError, f.read)
 
     def test_read_truncated(self):
         # Drop stream epilogue: 4 bytes checksum

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to