Skip to content

Commit f9588b1

Browse files
committed
Make _open_zst logic correct for append mode
1 parent c92f28c commit f9588b1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/xopen/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,16 +518,14 @@ def _open_zst(
518518

519519
if zstandard is None:
520520
raise ImportError("zstandard module (python-zstandard) not available")
521-
if compresslevel is not None and "w" in mode:
521+
if compresslevel is not None and "r" not in mode:
522522
cctx = zstandard.ZstdCompressor(level=compresslevel)
523523
else:
524524
cctx = None
525525
f = zstandard.open(filename, mode, cctx=cctx) # type: ignore
526526
if mode == "rb":
527527
return io.BufferedReader(f)
528-
elif mode == "wb":
529-
return io.BufferedWriter(f)
530-
return f
528+
return io.BufferedWriter(f) # mode "ab" and "wb"
531529

532530

533531
def _open_gz(

0 commit comments

Comments
 (0)